K-means is a simple unsupervised machine learning algorithm for clustering. From the textbook, the algorithm is as follows:
K centroids (K rows chosen at random).The distances are calculated by a squared error function.
\[\sum_{j=1}^{k} \sum_{i=1}^{n}||x_i^{(j)} - c_j||^2\]
Note that we need to know the number of clusters beforehand to be able to calculate the centroids.
Let’s look at an example with K-Means. For easier visualization, we’ll use a pretty simple dataset built into R, iris.
str(iris)
## 'data.frame': 150 obs. of 5 variables:
## $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
## $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
## $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
## $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
## $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
head(iris, 5)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
This dataset has 3 different species of irises, with 150 observations of measurements of petals and sepals. Let’s try to cluster based on sepal length. Since we know that there are 3 different species in the dataset, we can assume that there will be three clusters.
To start, our data looks like this:
library(ggplot2)
ggplot(iris, aes(Petal.Length, Petal.Width)) + geom_point()
Let’s use the kmeans function.
iris_cluster <- kmeans(iris[, 3:4], 3)
iris_cluster
## K-means clustering with 3 clusters of sizes 50, 54, 46
##
## Cluster means:
## Petal.Length Petal.Width
## 1 1.462000 0.246000
## 2 4.292593 1.359259
## 3 5.626087 2.047826
##
## Clustering vector:
## [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [36] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [71] 2 2 2 2 2 2 2 3 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
## [106] 3 2 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 2 3 3 2 2 3 3 3 3 3 3 3 3 3 3 2 3
## [141] 3 3 3 3 3 3 3 3 3 3
##
## Within cluster sum of squares by cluster:
## [1] 2.02200 14.22741 15.16348
## (between_SS / total_SS = 94.3 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss"
## [5] "tot.withinss" "betweenss" "size" "iter"
## [9] "ifault"
If we plot the graph with colors for each cluster, we get the following:
ggplot(iris, aes(Petal.Length, Petal.Width, color = as.factor(iris_cluster$cluster))) + geom_point()
Let’s compare this to actual species given.
iris$Species.Sort <- factor(iris$Species, levels=c("virginica", "versicolor", "setosa"))
ggplot(iris, aes(Petal.Length, Petal.Width, color = factor(iris$Species.Sort))) + geom_point()
There are some minor differences. We can see where kmeans failed.
table(iris_cluster$cluster, iris$Species)
##
## setosa versicolor virginica
## 1 50 0 0
## 2 0 48 6
## 3 0 2 44
R’s built-in kmeans also has some helpful initialization options:
iter.max: number of iterations to run. Default is set to 10.
nstart: number of times to try to pick the best center. Default is set to 1.algorithm: default is Lloyd/Forgy (described above). MacQueen and Hartigan-Wong have essentially the same distance calculation, but are smarter performance-wise. For instance, MacQueen updates the centroids any time a point is moved.K-Means does have a few drawbacks.
The last three points are particularly important to note. In these cases, K-Means may not be the best clustering algorithm of choice. We can see this in the next section.
Let’s take a dataset that has a concave U shape in data. For this, we can use the artificially dataset smiley.
library(mlbench)
smiley <- mlbench.smiley()
str(smiley)
## List of 2
## $ x : num [1:500, 1:2] -0.802 -0.743 -0.933 -0.924 -0.686 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : NULL
## .. ..$ : chr [1:2] "x4" ""
## $ classes: Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 1 1 1 1 ...
## - attr(*, "class")= chr [1:2] "mlbench.smiley" "mlbench"
smiley_data <- data.frame(smiley$x)
colnames(smiley_data)[colnames(smiley_data)=="x4"] <- "x"
colnames(smiley_data)[colnames(smiley_data)=="V2"] <- "y"
str(smiley_data)
## 'data.frame': 500 obs. of 2 variables:
## $ x: num -0.802 -0.743 -0.933 -0.924 -0.686 ...
## $ y: num 1.035 1.01 0.965 0.939 0.926 ...
ggplot(smiley_data, aes(x, y)) + geom_point()
We know there’s four clusters (two eyes, a nose, and a mouth). Let’s take a look at what kmeans produces.
smiley_cluster <- kmeans(smiley_data, 4, iter.max = 50)
smiley_cluster
## K-means clustering with 4 clusters of sizes 80, 129, 208, 83
##
## Cluster means:
## x y
## 1 -0.6991541 -0.4581949
## 2 0.4137118 -0.7324549
## 3 -0.3127123 0.6038361
## 4 0.8117034 1.0022588
##
## Clustering vector:
## [1] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [36] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [71] 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## [106] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## [141] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3
## [176] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [211] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [246] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [281] 3 3 3 3 3 3 3 3 3 3 3 2 1 2 1 2 1 1 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2
## [316] 1 2 2 1 1 1 1 2 1 2 2 2 2 2 2 2 2 1 1 2 1 1 1 2 1 2 1 1 1 2 1 1 2 1 1
## [351] 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 2 1 1 2 2 1 1 2 1 2 1 2 1
## [386] 2 1 2 2 2 2 1 2 1 1 1 2 1 2 2 2 2 1 1 1 2 2 1 1 1 1 1 2 1 1 2 2 2 2 2
## [421] 2 2 2 1 2 2 2 1 2 2 1 2 2 2 2 2 1 2 1 2 1 1 1 2 2 2 1 1 2 1 2 1 1 1 1
## [456] 2 2 2 1 2 2 1 2 2 2 2 1 1 2 2 1 2 2 2 2 1 2 2 2 2 1 2 2 2 2 1 2 2 1 2
## [491] 1 2 1 2 1 1 2 2 2 1
##
## Within cluster sum of squares by cluster:
## [1] 11.10700 24.52663 59.15788 1.76754
## (between_SS / total_SS = 79.3 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss"
## [5] "tot.withinss" "betweenss" "size" "iter"
## [9] "ifault"
smiley_cluster$cluster_factor <- as.factor(smiley_cluster$cluster)
centroids <- data.frame(smiley_cluster$centers)
centroids
## x y
## 1 -0.6991541 -0.4581949
## 2 0.4137118 -0.7324549
## 3 -0.3127123 0.6038361
## 4 0.8117034 1.0022588
ggplot(data=smiley_data, aes(x, y, color=smiley_cluster$cluster_factor)) + geom_point() + geom_point(data=centroids, aes(x, y), color="black", size=3)
We mark the centroids for each cluster. As we can see, kmeans struggled a lot with the U shape of the mouth, breaking it up into two curves. In addition, with the way the clusters are defined, it grouped the left eye with the nose.
A better algorithm for clustering in these instances is a mixture model, which uses a probability distribution as opposed to hard assignments. The Gaussian mixture model in particular handles data with more skew/kurtosis and is more flexible in terms of cluster covariance, which means it can handle shapes that K-Means cannot.
We can take a look at how GMM handles this dataset.
We initialize GMM the same way we initialize kmeans, giving it the number of clusters we want.
library(mclust)
## Package 'mclust' version 5.3
## Type 'citation("mclust")' for citing this R package in publications.
smiley_gmm <- Mclust(smiley_data, G=4)
smiley_gmm
## 'Mclust' model object:
## best model: diagonal, varying volume and shape (VVI) with 4 components
ggplot(data=smiley_data, aes(x, y, color=as.factor(smiley_gmm$classification))) + geom_point()
Here, we can see that even an out of the box GMM call gives us much more accurate clusters.
General idea behind clustering analysis is to predict or discover outcomes from measured predictors.The goal of this overview was to try many methods on a dataset often used for cluster analysis. Provided are some visualizations between methods of dendrogram plotting, as well as an example utility of hClust to order variables in a correlation matrix.
seed.df2 <- transform(seed.df,
RankArea = rank(-Area,
ties.method = "average"))
seed.df <- seed.df2[,-8]
seed_labels <- seed.df2[,8]
require(colorspace)
seed_col <- sort(sequential_hcl(203, power = 2))[as.numeric(seed_labels)] #Sequential HCL with quadratic power
rm(seed_labels)
rm(seed.df2)
#Plot matrix
pairs(seed.df, col = seed_col,
main = "Pairwise comparison of seeds parameters ranked by area",
lower.panel = NULL,
pch = 20, cex = 1.0)
data<-read.csv("Files/Malavika/cluster.csv",header = TRUE, sep=",")
str(data)
## 'data.frame': 53 obs. of 23 variables:
## $ State : Factor w/ 53 levels "Alabama","Alaska",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ Amethyst : num 619 601 NA 545 342 ...
## $ Aquamarine : num 1413 1193 NA 865 NA ...
## $ Black.Diamond : num NA NA NA 923 NA ...
## $ Blue.Topaz : num 936 NA NA 552 1075 ...
## $ Citrine : num 424 NA NA 254 581 ...
## $ Diamond : num NA NA NA NA NA ...
## $ Emerald : num 1564 1404 NA 1836 1834 ...
## $ Garnet : num 930 NA NA 1352 NA ...
## $ Morganite : num NA NA NA 696 NA NA 641 NA NA NA ...
## $ Peridot : num 549 NA NA 968 NA ...
## $ Pink.Sapphire : num NA 2393 NA 736 NA ...
## $ Pink.Tourmaline: num NA 1000 1369 1750 NA ...
## $ Plain : num NA NA NA 536 NA ...
## $ Ruby : num 1991 NA NA 2211 1822 ...
## $ Sapphire : num 1368 2343 NA 1325 NA ...
## $ SI.Diamond : num NA 1799 NA 1325 577 ...
## $ Tanzanite : num 280 1453 NA 1298 680 ...
## $ VS.Diamond : num NA NA NA 1169 NA ...
## $ VVS.Diamond : num NA NA NA NA NA ...
## $ White.Sapphire : num NA NA NA 673 NA NA 880 NA NA 460 ...
## $ White.Topaz : num NA NA NA NA NA ...
## $ Grand.Total : num 1105 1292 1369 1193 780 ...
data[is.na(data)]<-0
datascaled<-scale(data[2:22])
datanew<-data.frame(data$State,datascaled)
rownames(datanew) <- data$State
dm<-dist(datanew,method="euclidean")
## Warning in dist(datanew, method = "euclidean"): NAs introduced by coercion
#using the euclidean method of calculating distance.
as.matrix(dm)
## Alabama Alaska Alberta Arizona Arkansas Armed Forces
## Alabama 0.000000 6.458014 5.938607 5.549891 4.225919 5.451675
## Alaska 6.458014 0.000000 6.556102 6.622259 6.829761 6.877432
## Alberta 5.938607 6.556102 0.000000 7.222525 4.561552 4.434178
## Arizona 5.549891 6.622259 7.222525 0.000000 6.735130 6.715123
## Arkansas 4.225919 6.829761 4.561552 6.735130 0.000000 3.856893
## Armed Forces 5.451675 6.877432 4.434178 6.715123 3.856893 0.000000
## California 7.185794 6.907958 8.681089 4.875951 7.785277 8.091055
## Colorado 6.591717 6.209829 8.190231 5.910030 7.479995 7.642559
## Connecticut 4.785040 5.595497 5.960058 5.695072 5.226764 5.140044
## Delaware 7.237935 6.364649 7.453248 7.718397 6.896935 6.053158
## Florida 5.885729 7.576403 8.162022 4.887118 6.742404 7.057881
## Georgia 4.512216 6.732959 5.511730 4.480849 5.650880 4.989234
## Hawaii 6.569188 7.208045 7.783550 7.032423 7.081671 7.138056
## Idaho 5.102335 5.094759 6.133954 6.051524 5.775522 5.548175
## Illinois 6.314432 8.150782 8.884725 6.834064 7.435443 7.819200
## Indiana 4.983077 5.753462 6.169430 4.805129 5.231410 5.089304
## Iowa 6.299427 7.268197 6.298100 5.563254 5.950419 4.851111
## Kansas 7.397043 8.604726 7.411567 7.720489 7.376899 7.013929
## Kentucky 4.372414 5.769216 5.995290 6.288914 5.516032 5.595574
## Louisiana 4.452699 6.615511 7.069131 5.156843 5.119941 5.887849
## Maine 5.293218 5.282709 4.221968 5.877516 4.867506 5.569170
## Maryland 8.093639 8.003989 9.753571 6.472942 8.745200 8.728376
## Massachusetts 5.392543 6.375656 7.706540 3.472857 6.839165 6.466005
## Michigan 4.808472 7.012517 6.792158 5.303960 5.515546 6.748488
## Minnesota 4.700909 7.964598 7.831709 5.807552 4.853899 6.301982
## Mississippi 3.774816 5.326722 4.904107 6.726372 4.701935 5.189008
## Missouri 3.563939 6.745481 7.075855 5.088364 4.981031 5.780591
## Montana 4.866612 4.608081 4.490560 6.773789 4.515885 4.084661
## Nebraska 6.504862 6.970077 6.503546 5.786813 7.125340 7.069650
## Nevada 5.267194 7.276109 5.753505 6.652513 4.865336 4.800257
## New Hampshire 4.030752 6.240840 4.718106 6.225590 3.270077 4.202395
## New Jersey 6.503568 7.378009 6.662825 4.259374 6.587982 6.468605
## New Mexico 5.618718 6.719694 5.653526 7.184587 5.206213 5.551038
## New York 6.249322 8.427771 8.855705 5.063408 7.603144 7.606226
## North Carolina 6.998369 7.753897 8.426676 6.006001 7.790330 7.902163
## North Dakota 9.191299 8.823546 8.950400 9.631094 7.682169 8.965781
## Ohio 4.773265 6.663065 6.491194 3.641898 5.862354 5.823620
## Oklahoma 4.782860 6.996699 6.270884 4.431446 6.146751 5.576427
## Oregon 4.064872 6.727814 6.662351 6.005467 3.975158 5.316895
## Pennsylvania 7.450679 7.121428 8.635543 5.977805 8.198800 8.179681
## Rhode Island 4.232285 7.082969 6.718567 7.192322 5.380866 5.610010
## South Carolina 6.555781 8.974856 9.576543 5.262589 7.755976 8.262035
## South Dakota 5.319670 6.607146 2.393359 7.663449 3.857254 3.682592
## Tennessee 4.606873 7.524248 8.198124 6.013190 5.811730 6.814115
## Texas 6.197279 7.510870 8.098935 5.184887 6.629659 7.168956
## Utah 8.762303 9.297339 9.084360 8.704028 8.516727 7.466403
## Vermont 5.149541 6.761137 2.498740 7.621458 3.320485 3.941580
## Virginia 4.944948 6.504468 6.219916 3.627328 6.087228 5.632139
## Washington 5.716118 7.197493 7.648839 6.318643 5.974328 5.627650
## West Virginia 4.407156 7.237112 4.366555 6.781851 4.848998 4.866620
## Wisconsin 6.120516 6.813791 7.019624 5.826823 5.454567 5.995199
## Wyoming 4.915825 6.411280 6.064700 7.182683 5.037459 4.899935
## Grand Total 6.218044 6.649416 7.984547 4.274130 6.983158 7.271430
## California Colorado Connecticut Delaware Florida
## Alabama 7.185794 6.591717 4.785040 7.237935 5.885729
## Alaska 6.907958 6.209829 5.595497 6.364649 7.576403
## Alberta 8.681089 8.190231 5.960058 7.453248 8.162022
## Arizona 4.875951 5.910030 5.695072 7.718397 4.887118
## Arkansas 7.785277 7.479995 5.226764 6.896935 6.742404
## Armed Forces 8.091055 7.642559 5.140044 6.053158 7.057881
## California 0.000000 5.424481 6.369320 7.979402 4.452789
## Colorado 5.424481 0.000000 5.362504 8.141139 5.915216
## Connecticut 6.369320 5.362504 0.000000 6.585539 5.389453
## Delaware 7.979402 8.141139 6.585539 0.000000 7.176644
## Florida 4.452789 5.915216 5.389453 7.176644 0.000000
## Georgia 6.092672 5.523206 5.228045 7.529675 5.337328
## Hawaii 7.630064 6.782499 6.197700 9.302851 8.393797
## Idaho 7.102374 6.573462 5.701367 6.367252 6.208132
## Illinois 5.449606 7.188713 7.302879 7.746595 5.961508
## Indiana 5.797307 5.889190 4.414236 5.741255 4.019368
## Iowa 6.204609 6.715460 4.958656 6.599537 4.921421
## Kansas 8.905964 7.312476 6.746150 8.363158 7.343258
## Kentucky 7.089404 6.464372 5.170206 6.313514 6.053618
## Louisiana 6.625641 6.801513 4.931743 7.081129 4.463888
## Maine 7.542683 7.014015 6.139437 7.340093 7.105972
## Maryland 4.789696 7.508220 8.533523 8.778590 6.973649
## Massachusetts 5.114866 6.256095 6.015409 7.616973 5.167417
## Michigan 6.374332 6.872394 5.432203 7.383262 4.849294
## Minnesota 6.682124 7.076054 6.200400 8.318038 4.977421
## Mississippi 7.925699 7.382828 5.060682 6.392635 6.655417
## Missouri 6.526190 6.784031 5.610006 7.697947 4.952425
## Montana 7.809604 7.077124 4.990817 4.103663 6.685003
## Nebraska 7.430779 7.170333 7.197735 8.554941 6.940012
## Nevada 7.519307 7.502369 6.303371 7.145776 6.509763
## New Hampshire 7.590397 7.041917 4.371487 6.281477 6.315661
## New Jersey 4.796961 6.661809 5.706699 7.402078 3.897598
## New Mexico 7.457747 5.134640 5.859649 7.124186 6.833203
## New York 4.772579 6.858847 6.406783 8.223225 4.376549
## North Carolina 6.486866 6.829243 6.017827 8.422485 4.232857
## North Dakota 10.648191 10.732955 9.436172 9.572150 10.360092
## Ohio 5.627328 5.889494 5.277582 7.404879 3.911594
## Oklahoma 6.310038 6.628926 6.126956 6.920917 5.626614
## Oregon 6.624895 5.970400 4.312459 7.607843 5.303754
## Pennsylvania 6.125095 4.381066 6.960579 8.056631 6.424759
## Rhode Island 7.723668 6.896976 5.748315 7.910543 5.948382
## South Carolina 7.205556 8.308857 7.034052 9.339922 5.933449
## South Dakota 8.792791 8.120123 5.658362 6.884977 7.843544
## Tennessee 6.406763 6.874478 5.669693 7.565404 4.748354
## Texas 5.388334 4.889869 6.006434 7.884593 4.433368
## Utah 8.061904 8.058331 6.676023 8.382922 6.517269
## Vermont 8.708832 8.042605 5.436103 7.148112 7.686588
## Virginia 5.707211 5.582686 5.402257 6.793980 4.799523
## Washington 6.853838 6.057213 5.590082 6.302715 4.921293
## West Virginia 8.845652 8.273067 5.056785 7.814470 7.831506
## Wisconsin 6.370484 7.417557 6.862335 7.082930 5.833695
## Wyoming 7.770176 7.430232 5.426891 6.325067 6.679687
## Grand Total 2.442488 4.109117 5.414111 7.635680 3.667190
## Georgia Hawaii Idaho Illinois Indiana Iowa
## Alabama 4.512216 6.569188 5.102335 6.314432 4.983077 6.299427
## Alaska 6.732959 7.208045 5.094759 8.150782 5.753462 7.268197
## Alberta 5.511730 7.783550 6.133954 8.884725 6.169430 6.298100
## Arizona 4.480849 7.032423 6.051524 6.834064 4.805129 5.563254
## Arkansas 5.650880 7.081671 5.775522 7.435443 5.231410 5.950419
## Armed Forces 4.989234 7.138056 5.548175 7.819200 5.089304 4.851111
## California 6.092672 7.630064 7.102374 5.449606 5.797307 6.204609
## Colorado 5.523206 6.782499 6.573462 7.188713 5.889190 6.715460
## Connecticut 5.228045 6.197700 5.701367 7.302879 4.414236 4.958656
## Delaware 7.529675 9.302851 6.367252 7.746595 5.741255 6.599537
## Florida 5.337328 8.393797 6.208132 5.961508 4.019368 4.921421
## Georgia 0.000000 6.750297 5.281656 6.711226 4.271838 5.203500
## Hawaii 6.750297 0.000000 6.888715 8.628018 7.708991 7.140632
## Idaho 5.281656 6.888715 0.000000 6.904785 4.867216 5.097081
## Illinois 6.711226 8.628018 6.904785 0.000000 6.216753 6.914213
## Indiana 4.271838 7.708991 4.867216 6.216753 0.000000 4.523287
## Iowa 5.203500 7.140632 5.097081 6.914213 4.523287 0.000000
## Kansas 7.202238 8.267355 7.136644 9.203973 6.740914 7.210568
## Kentucky 4.979064 6.552144 2.494074 6.998819 4.599057 4.924156
## Louisiana 5.630785 7.895766 6.203301 6.415804 4.390920 6.064292
## Maine 5.195503 7.091681 4.271554 7.492483 5.311778 6.558231
## Maryland 7.767793 9.256796 8.109737 5.487027 7.611905 8.470258
## Massachusetts 4.452077 7.356625 5.613256 7.261024 5.293372 6.224197
## Michigan 5.103176 8.929174 6.549170 7.689075 5.064910 7.113830
## Minnesota 5.827999 8.418906 6.214278 6.565767 5.137562 6.192119
## Mississippi 5.426846 8.156091 4.866298 7.037977 4.910308 6.548849
## Missouri 5.159653 7.046491 5.540222 6.240232 4.926120 6.275760
## Montana 5.560399 7.374638 3.788530 7.343585 4.461821 5.461255
## Nebraska 4.877631 7.583563 5.851732 8.863687 6.233945 6.981872
## Nevada 5.539872 7.003364 6.616295 7.567007 5.426482 6.349178
## New Hampshire 5.702455 6.446677 4.848501 7.203726 4.623185 4.717626
## New Jersey 4.481658 8.812251 6.854996 7.084215 4.269454 5.312699
## New Mexico 5.090302 7.132172 6.212914 7.347758 6.066660 6.372687
## New York 5.592145 9.094107 6.779256 5.086406 5.189313 6.267474
## North Carolina 6.492492 8.674060 7.446499 8.295646 5.182880 6.843864
## North Dakota 9.624348 10.192808 8.238749 10.458669 8.565928 9.518730
## Ohio 3.595545 7.206117 5.227263 6.565286 4.250188 4.953120
## Oklahoma 4.192569 5.888685 4.916438 6.813031 5.396766 4.960254
## Oregon 5.470112 6.533233 6.189566 7.438703 5.066064 5.964436
## Pennsylvania 6.502955 8.631923 7.171559 7.700079 6.071833 7.524562
## Rhode Island 4.828714 8.186827 5.970258 7.787660 5.838866 6.901866
## South Carolina 7.392903 8.869245 8.173157 7.520300 6.086222 7.469876
## South Dakota 5.734253 7.479454 5.648095 8.352783 5.972264 6.212878
## Tennessee 5.705411 7.902641 5.868657 6.466157 5.270415 6.485607
## Texas 5.219959 7.829138 6.090771 6.668738 5.543089 6.001264
## Utah 7.053998 9.399234 7.865078 8.723810 5.477808 6.477314
## Vermont 5.819848 7.444364 5.642209 8.461158 6.115764 6.105436
## Virginia 3.542946 6.734386 4.879180 7.167333 4.559654 4.543963
## Washington 5.142458 8.710108 6.069777 7.090325 3.830936 6.664780
## West Virginia 5.634109 7.711825 6.437182 8.037606 6.165578 6.860840
## Wisconsin 6.279280 7.694510 5.308922 6.725349 5.284446 6.245025
## Wyoming 5.185658 7.762876 6.195199 6.934846 4.578402 6.896238
## Grand Total 5.089513 7.333753 6.373841 5.266276 4.921929 5.891074
## Kansas Kentucky Louisiana Maine Maryland
## Alabama 7.397043 4.372414 4.452699 5.293218 8.093639
## Alaska 8.604726 5.769216 6.615511 5.282709 8.003989
## Alberta 7.411567 5.995290 7.069131 4.221968 9.753571
## Arizona 7.720489 6.288914 5.156843 5.877516 6.472942
## Arkansas 7.376899 5.516032 5.119941 4.867506 8.745200
## Armed Forces 7.013929 5.595574 5.887849 5.569170 8.728376
## California 8.905964 7.089404 6.625641 7.542683 4.789696
## Colorado 7.312476 6.464372 6.801513 7.014015 7.508220
## Connecticut 6.746150 5.170206 4.931743 6.139437 8.533523
## Delaware 8.363158 6.313514 7.081129 7.340093 8.778590
## Florida 7.343258 6.053618 4.463888 7.105972 6.973649
## Georgia 7.202238 4.979064 5.630785 5.195503 7.767793
## Hawaii 8.267355 6.552144 7.895766 7.091681 9.256796
## Idaho 7.136644 2.494074 6.203301 4.271554 8.109737
## Illinois 9.203973 6.998819 6.415804 7.492483 5.487027
## Indiana 6.740914 4.599057 4.390920 5.311778 7.611905
## Iowa 7.210568 4.924156 6.064292 6.558231 8.470258
## Kansas 0.000000 6.970763 8.089403 6.351712 9.807778
## Kentucky 6.970763 0.000000 6.548283 5.197295 8.741115
## Louisiana 8.089403 6.548283 0.000000 6.087485 7.366151
## Maine 6.351712 5.197295 6.087485 0.000000 8.025654
## Maryland 9.807778 8.741115 7.366151 8.025654 0.000000
## Massachusetts 8.489479 5.846212 5.674934 6.479105 6.228201
## Michigan 8.429864 6.243535 4.637338 6.352609 8.002383
## Minnesota 8.614830 6.214171 4.670789 6.945337 8.044596
## Mississippi 7.668144 4.973478 5.074344 4.386038 8.444188
## Missouri 7.917208 5.903365 3.131845 5.631463 6.981011
## Montana 7.038329 3.873661 5.549094 4.434018 8.647836
## Nebraska 8.187371 5.896632 7.040334 5.971019 9.279251
## Nevada 6.935151 6.315286 5.301318 5.710532 7.452606
## New Hampshire 6.802157 4.147641 4.948457 5.206466 8.835816
## New Jersey 7.941635 6.791874 5.549812 6.483843 7.403636
## New Mexico 7.490999 6.031380 6.159567 5.789630 8.474956
## New York 8.285018 6.533630 6.272072 7.698165 5.853669
## North Carolina 7.521103 7.470538 5.516528 7.415345 8.744170
## North Dakota 10.389917 8.678948 9.416963 7.148142 11.242309
## Ohio 7.221690 5.449320 3.804193 5.393729 6.972090
## Oklahoma 6.897179 4.694252 5.899778 5.448801 7.121522
## Oregon 7.154538 5.628527 4.420353 6.535852 8.383445
## Pennsylvania 8.320207 7.199063 7.156796 7.458868 7.034796
## Rhode Island 7.834624 5.756226 5.284769 6.535732 8.722184
## South Carolina 9.817396 8.061831 5.131123 8.656070 8.216247
## South Dakota 6.947364 5.475771 6.538900 4.413409 9.439669
## Tennessee 8.943009 5.576714 4.917737 7.324797 8.450909
## Texas 8.209651 6.420524 5.131024 6.607062 6.665696
## Utah 8.623943 7.300432 8.260537 8.981313 10.223566
## Vermont 7.076865 5.384558 6.440858 4.526146 9.669427
## Virginia 6.050832 4.688628 5.914366 5.310607 7.594713
## Washington 6.329396 5.919382 5.562652 6.613086 7.850963
## West Virginia 7.711189 6.070705 5.818086 5.441244 9.255390
## Wisconsin 7.953246 6.097142 5.311139 5.189702 5.931201
## Wyoming 8.005924 6.064219 5.393941 5.563723 8.299394
## Grand Total 7.772135 6.443837 5.507967 6.691132 5.075635
## Massachusetts Michigan Minnesota Mississippi Missouri
## Alabama 5.392543 4.808472 4.700909 3.774816 3.563939
## Alaska 6.375656 7.012517 7.964598 5.326722 6.745481
## Alberta 7.706540 6.792158 7.831709 4.904107 7.075855
## Arizona 3.472857 5.303960 5.807552 6.726372 5.088364
## Arkansas 6.839165 5.515546 4.853899 4.701935 4.981031
## Armed Forces 6.466005 6.748488 6.301982 5.189008 5.780591
## California 5.114866 6.374332 6.682124 7.925699 6.526190
## Colorado 6.256095 6.872394 7.076054 7.382828 6.784031
## Connecticut 6.015409 5.432203 6.200400 5.060682 5.610006
## Delaware 7.616973 7.383262 8.318038 6.392635 7.697947
## Florida 5.167417 4.849294 4.977421 6.655417 4.952425
## Georgia 4.452077 5.103176 5.827999 5.426846 5.159653
## Hawaii 7.356625 8.929174 8.418906 8.156091 7.046491
## Idaho 5.613256 6.549170 6.214278 4.866298 5.540222
## Illinois 7.261024 7.689075 6.565767 7.037977 6.240232
## Indiana 5.293372 5.064910 5.137562 4.910308 4.926120
## Iowa 6.224197 7.113830 6.192119 6.548849 6.275760
## Kansas 8.489479 8.429864 8.614830 7.668144 7.917208
## Kentucky 5.846212 6.243535 6.214171 4.973478 5.903365
## Louisiana 5.674934 4.637338 4.670789 5.074344 3.131845
## Maine 6.479105 6.352609 6.945337 4.386038 5.631463
## Maryland 6.228201 8.002383 8.044596 8.444188 6.981011
## Massachusetts 0.000000 4.825644 5.631808 6.289814 4.805791
## Michigan 4.825644 0.000000 5.121099 5.563666 5.164710
## Minnesota 5.631808 5.121099 0.000000 6.196047 3.969467
## Mississippi 6.289814 5.563666 6.196047 0.000000 4.812340
## Missouri 4.805791 5.164710 3.969467 4.812340 0.000000
## Montana 6.635010 6.144631 6.848451 3.690420 5.865714
## Nebraska 6.090249 6.008477 7.449317 7.686031 6.837371
## Nevada 6.679064 6.719875 7.032359 5.762934 5.173519
## New Hampshire 6.841214 6.035567 5.663739 4.955200 5.299715
## New Jersey 4.888535 4.406335 5.979373 6.664380 5.827660
## New Mexico 7.163839 6.585197 7.041983 5.618244 6.438727
## New York 5.282642 5.783508 5.744175 7.451404 6.328482
## North Carolina 6.159327 6.011770 6.703591 7.009354 5.452462
## North Dakota 9.636062 9.644444 9.959241 8.182110 9.554006
## Ohio 4.045568 4.501246 5.488255 5.623936 4.521139
## Oklahoma 4.742192 6.480878 6.672593 6.017652 5.189413
## Oregon 5.804385 4.784171 4.123454 5.999159 4.395396
## Pennsylvania 6.115796 6.939652 7.702952 7.743356 6.901824
## Rhode Island 5.941597 5.019436 5.414325 5.104582 4.639582
## South Carolina 6.024039 6.590600 5.629351 7.967452 5.711664
## South Dakota 7.656587 6.814901 7.328437 4.131344 6.529536
## Tennessee 5.321992 4.473132 3.623236 6.327798 4.268819
## Texas 5.386818 5.324044 6.008542 7.061935 5.292006
## Utah 8.659978 8.576313 8.438402 8.579812 8.560707
## Vermont 7.614492 6.396823 6.947430 4.289154 6.470481
## Virginia 4.246912 5.554418 6.001199 6.106232 5.128780
## Washington 5.675188 5.106184 5.338240 6.103148 5.563479
## West Virginia 7.029111 6.093132 7.228503 4.219397 6.275096
## Wisconsin 5.924734 6.477349 5.868447 6.167304 4.845933
## Wyoming 6.739440 6.319361 6.656422 3.849856 5.044458
## Grand Total 4.526745 5.275256 5.802195 7.003535 5.443779
## Montana Nebraska Nevada New Hampshire New Jersey
## Alabama 4.866612 6.504862 5.267194 4.030752 6.503568
## Alaska 4.608081 6.970077 7.276109 6.240840 7.378009
## Alberta 4.490560 6.503546 5.753505 4.718106 6.662825
## Arizona 6.773789 5.786813 6.652513 6.225590 4.259374
## Arkansas 4.515885 7.125340 4.865336 3.270077 6.587982
## Armed Forces 4.084661 7.069650 4.800257 4.202395 6.468605
## California 7.809604 7.430779 7.519307 7.590397 4.796961
## Colorado 7.077124 7.170333 7.502369 7.041917 6.661809
## Connecticut 4.990817 7.197735 6.303371 4.371487 5.706699
## Delaware 4.103663 8.554941 7.145776 6.281477 7.402078
## Florida 6.685003 6.940012 6.509763 6.315661 3.897598
## Georgia 5.560399 4.877631 5.539872 5.702455 4.481658
## Hawaii 7.374638 7.583563 7.003364 6.446677 8.812251
## Idaho 3.788530 5.851732 6.616295 4.848501 6.854996
## Illinois 7.343585 8.863687 7.567007 7.203726 7.084215
## Indiana 4.461821 6.233945 5.426482 4.623185 4.269454
## Iowa 5.461255 6.981872 6.349178 4.717626 5.312699
## Kansas 7.038329 8.187371 6.935151 6.802157 7.941635
## Kentucky 3.873661 5.896632 6.315286 4.147641 6.791874
## Louisiana 5.549094 7.040334 5.301318 4.948457 5.549812
## Maine 4.434018 5.971019 5.710532 5.206466 6.483843
## Maryland 8.647836 9.279251 7.452606 8.835816 7.403636
## Massachusetts 6.635010 6.090249 6.679064 6.841214 4.888535
## Michigan 6.144631 6.008477 6.719875 6.035567 4.406335
## Minnesota 6.848451 7.449317 7.032359 5.663739 5.979373
## Mississippi 3.690420 7.686031 5.762934 4.955200 6.664380
## Missouri 5.865714 6.837371 5.173519 5.299715 5.827660
## Montana 0.000000 6.457812 5.214852 3.654956 6.798800
## Nebraska 6.457812 0.000000 7.274766 6.379948 5.897104
## Nevada 5.214852 7.274766 0.000000 4.822413 6.894747
## New Hampshire 3.654956 6.379948 4.822413 0.000000 6.673016
## New Jersey 6.798800 5.897104 6.894747 6.673016 0.000000
## New Mexico 5.065790 7.149134 5.371428 5.489742 7.156392
## New York 7.773660 7.795013 7.580724 7.227466 5.276604
## North Carolina 7.566820 7.520702 7.471178 7.531054 4.780133
## North Dakota 8.186247 10.678236 9.473165 8.544177 10.036331
## Ohio 5.622588 5.277986 5.213383 5.376355 4.490014
## Oklahoma 5.354831 6.000114 4.569980 5.306841 6.171824
## Oregon 5.768759 6.209362 5.556000 4.036584 6.037221
## Pennsylvania 7.505236 7.583019 7.676239 7.633546 6.400008
## Rhode Island 5.712947 6.402327 5.756628 5.879335 6.538849
## South Carolina 8.476217 8.596137 8.074329 7.123741 6.770492
## South Dakota 3.676748 7.282063 4.889343 4.197512 7.322902
## Tennessee 6.513385 6.486458 7.679118 5.918545 5.684491
## Texas 6.890048 6.905791 6.450885 6.633053 5.511662
## Utah 7.840617 9.454008 8.107921 8.117123 7.277510
## Vermont 3.963550 7.125633 5.330111 3.906106 7.174625
## Virginia 5.604587 4.853765 5.857743 5.438581 4.429281
## Washington 5.735890 7.012228 6.296989 6.319814 5.592976
## West Virginia 5.100971 7.654238 5.875271 4.562432 7.293378
## Wisconsin 5.675933 7.611519 4.729871 5.810459 6.648407
## Wyoming 4.719607 8.279431 4.955522 5.926614 6.706337
## Grand Total 7.067734 6.657441 6.891992 6.812184 4.143404
## New Mexico New York North Carolina North Dakota Ohio
## Alabama 5.618718 6.249322 6.998369 9.191299 4.773265
## Alaska 6.719694 8.427771 7.753897 8.823546 6.663065
## Alberta 5.653526 8.855705 8.426676 8.950400 6.491194
## Arizona 7.184587 5.063408 6.006001 9.631094 3.641898
## Arkansas 5.206213 7.603144 7.790330 7.682169 5.862354
## Armed Forces 5.551038 7.606226 7.902163 8.965781 5.823620
## California 7.457747 4.772579 6.486866 10.648191 5.627328
## Colorado 5.134640 6.858847 6.829243 10.732955 5.889494
## Connecticut 5.859649 6.406783 6.017827 9.436172 5.277582
## Delaware 7.124186 8.223225 8.422485 9.572150 7.404879
## Florida 6.833203 4.376549 4.232857 10.360092 3.911594
## Georgia 5.090302 5.592145 6.492492 9.624348 3.595545
## Hawaii 7.132172 9.094107 8.674060 10.192808 7.206117
## Idaho 6.212914 6.779256 7.446499 8.238749 5.227263
## Illinois 7.347758 5.086406 8.295646 10.458669 6.565286
## Indiana 6.066660 5.189313 5.182880 8.565928 4.250188
## Iowa 6.372687 6.267474 6.843864 9.518730 4.953120
## Kansas 7.490999 8.285018 7.521103 10.389917 7.221690
## Kentucky 6.031380 6.533630 7.470538 8.678948 5.449320
## Louisiana 6.159567 6.272072 5.516528 9.416963 3.804193
## Maine 5.789630 7.698165 7.415345 7.148142 5.393729
## Maryland 8.474956 5.853669 8.744170 11.242309 6.972090
## Massachusetts 7.163839 5.282642 6.159327 9.636062 4.045568
## Michigan 6.585197 5.783508 6.011770 9.644444 4.501246
## Minnesota 7.041983 5.744175 6.703591 9.959241 5.488255
## Mississippi 5.618244 7.451404 7.009354 8.182110 5.623936
## Missouri 6.438727 6.328482 5.452462 9.554006 4.521139
## Montana 5.065790 7.773660 7.566820 8.186247 5.622588
## Nebraska 7.149134 7.795013 7.520702 10.678236 5.277986
## Nevada 5.371428 7.580724 7.471178 9.473165 5.213383
## New Hampshire 5.489742 7.227466 7.531054 8.544177 5.376355
## New Jersey 7.156392 5.276604 4.780133 10.036331 4.490014
## New Mexico 0.000000 8.276070 7.836752 9.263648 5.384287
## New York 8.276070 0.000000 7.399846 10.954524 5.304849
## North Carolina 7.836752 7.399846 0.000000 10.768440 5.629634
## North Dakota 9.263648 10.954524 10.768440 0.000000 9.045486
## Ohio 5.384287 5.304849 5.629634 9.045486 0.000000
## Oklahoma 5.784805 6.270010 7.157084 9.703240 3.853859
## Oregon 5.834522 6.660920 6.375622 9.813806 5.183214
## Pennsylvania 6.370792 7.343944 6.379299 10.671674 6.418638
## Rhode Island 5.868621 7.050025 7.127356 10.718173 5.370204
## South Carolina 8.886953 6.493412 6.394603 10.704755 5.683324
## South Dakota 4.954748 8.653921 8.318375 8.687247 6.305190
## Tennessee 7.226178 5.998749 5.926952 10.180302 5.564127
## Texas 5.598018 5.759845 6.498103 9.719807 4.262804
## Utah 8.600500 7.321072 7.536111 11.592308 7.867264
## Vermont 4.922386 8.622720 8.266676 8.419410 6.236120
## Virginia 6.305446 5.688592 6.082835 9.755559 4.150500
## Washington 6.475412 5.590682 5.873186 9.970457 5.567255
## West Virginia 6.091679 7.720694 8.382340 8.910264 5.714675
## Wisconsin 6.707210 6.417604 7.463045 8.903015 5.390976
## Wyoming 5.938386 7.414808 7.071621 8.768103 6.237973
## Grand Total 6.228958 4.495561 5.174696 10.201884 4.585300
## Oklahoma Oregon Pennsylvania Rhode Island South Carolina
## Alabama 4.782860 4.064872 7.450679 4.232285 6.555781
## Alaska 6.996699 6.727814 7.121428 7.082969 8.974856
## Alberta 6.270884 6.662351 8.635543 6.718567 9.576543
## Arizona 4.431446 6.005467 5.977805 7.192322 5.262589
## Arkansas 6.146751 3.975158 8.198800 5.380866 7.755976
## Armed Forces 5.576427 5.316895 8.179681 5.610010 8.262035
## California 6.310038 6.624895 6.125095 7.723668 7.205556
## Colorado 6.628926 5.970400 4.381066 6.896976 8.308857
## Connecticut 6.126956 4.312459 6.960579 5.748315 7.034052
## Delaware 6.920917 7.607843 8.056631 7.910543 9.339922
## Florida 5.626614 5.303754 6.424759 5.948382 5.933449
## Georgia 4.192569 5.470112 6.502955 4.828714 7.392903
## Hawaii 5.888685 6.533233 8.631923 8.186827 8.869245
## Idaho 4.916438 6.189566 7.171559 5.970258 8.173157
## Illinois 6.813031 7.438703 7.700079 7.787660 7.520300
## Indiana 5.396766 5.066064 6.071833 5.838866 6.086222
## Iowa 4.960254 5.964436 7.524562 6.901866 7.469876
## Kansas 6.897179 7.154538 8.320207 7.834624 9.817396
## Kentucky 4.694252 5.628527 7.199063 5.756226 8.061831
## Louisiana 5.899778 4.420353 7.156796 5.284769 5.131123
## Maine 5.448801 6.535852 7.458868 6.535732 8.656070
## Maryland 7.121522 8.383445 7.034796 8.722184 8.216247
## Massachusetts 4.742192 5.804385 6.115796 5.941597 6.024039
## Michigan 6.480878 4.784171 6.939652 5.019436 6.590600
## Minnesota 6.672593 4.123454 7.702952 5.414325 5.629351
## Mississippi 6.017652 5.999159 7.743356 5.104582 7.967452
## Missouri 5.189413 4.395396 6.901824 4.639582 5.711664
## Montana 5.354831 5.768759 7.505236 5.712947 8.476217
## Nebraska 6.000114 6.209362 7.583019 6.402327 8.596137
## Nevada 4.569980 5.556000 7.676239 5.756628 8.074329
## New Hampshire 5.306841 4.036584 7.633546 5.879335 7.123741
## New Jersey 6.171824 6.037221 6.400008 6.538849 6.770492
## New Mexico 5.784805 5.834522 6.370792 5.868621 8.886953
## New York 6.270010 6.660920 7.343944 7.050025 6.493412
## North Carolina 7.157084 6.375622 6.379299 7.127356 6.394603
## North Dakota 9.703240 9.813806 10.671674 10.718173 10.704755
## Ohio 3.853859 5.183214 6.418638 5.370204 5.683324
## Oklahoma 0.000000 6.262900 7.063426 6.346805 7.214776
## Oregon 6.262900 0.000000 7.305276 4.171568 6.577092
## Pennsylvania 7.063426 7.305276 0.000000 8.236649 7.615488
## Rhode Island 6.346805 4.171568 8.236649 0.000000 8.658346
## South Carolina 7.214776 6.577092 7.615488 8.658346 0.000000
## South Dakota 5.906544 6.179472 8.723327 6.075385 9.216310
## Tennessee 6.749317 4.260792 7.308986 5.229568 5.944236
## Texas 5.648108 6.008431 5.226836 6.347943 7.397568
## Utah 8.255040 8.276947 8.828539 8.483404 9.513635
## Vermont 6.144165 5.710069 8.773149 5.897447 9.112723
## Virginia 3.650849 5.379701 6.236633 5.567495 7.548536
## Washington 6.613965 5.105833 6.394647 5.228611 7.262601
## West Virginia 6.108545 6.173761 8.711816 6.451735 7.613307
## Wisconsin 5.011600 6.490776 7.253764 6.937719 7.508077
## Wyoming 6.270546 6.298179 7.983332 5.501689 8.420822
## Grand Total 5.864088 5.657728 4.410200 6.750076 6.276222
## South Dakota Tennessee Texas Utah Vermont Virginia
## Alabama 5.319670 4.606873 6.197279 8.762303 5.149541 4.944948
## Alaska 6.607146 7.524248 7.510870 9.297339 6.761137 6.504468
## Alberta 2.393359 8.198124 8.098935 9.084360 2.498740 6.219916
## Arizona 7.663449 6.013190 5.184887 8.704028 7.621458 3.627328
## Arkansas 3.857254 5.811730 6.629659 8.516727 3.320485 6.087228
## Armed Forces 3.682592 6.814115 7.168956 7.466403 3.941580 5.632139
## California 8.792791 6.406763 5.388334 8.061904 8.708832 5.707211
## Colorado 8.120123 6.874478 4.889869 8.058331 8.042605 5.582686
## Connecticut 5.658362 5.669693 6.006434 6.676023 5.436103 5.402257
## Delaware 6.884977 7.565404 7.884593 8.382922 7.148112 6.793980
## Florida 7.843544 4.748354 4.433368 6.517269 7.686588 4.799523
## Georgia 5.734253 5.705411 5.219959 7.053998 5.819848 3.542946
## Hawaii 7.479454 7.902641 7.829138 9.399234 7.444364 6.734386
## Idaho 5.648095 5.868657 6.090771 7.865078 5.642209 4.879180
## Illinois 8.352783 6.466157 6.668738 8.723810 8.461158 7.167333
## Indiana 5.972264 5.270415 5.543089 5.477808 6.115764 4.559654
## Iowa 6.212878 6.485607 6.001264 6.477314 6.105436 4.543963
## Kansas 6.947364 8.943009 8.209651 8.623943 7.076865 6.050832
## Kentucky 5.475771 5.576714 6.420524 7.300432 5.384558 4.688628
## Louisiana 6.538900 4.917737 5.131024 8.260537 6.440858 5.914366
## Maine 4.413409 7.324797 6.607062 8.981313 4.526146 5.310607
## Maryland 9.439669 8.450909 6.665696 10.223566 9.669427 7.594713
## Massachusetts 7.656587 5.321992 5.386818 8.659978 7.614492 4.246912
## Michigan 6.814901 4.473132 5.324044 8.576313 6.396823 5.554418
## Minnesota 7.328437 3.623236 6.008542 8.438402 6.947430 6.001199
## Mississippi 4.131344 6.327798 7.061935 8.579812 4.289154 6.106232
## Missouri 6.529536 4.268819 5.292006 8.560707 6.470481 5.128780
## Montana 3.676748 6.513385 6.890048 7.840617 3.963550 5.604587
## Nebraska 7.282063 6.486458 6.905791 9.454008 7.125633 4.853765
## Nevada 4.889343 7.679118 6.450885 8.107921 5.330111 5.857743
## New Hampshire 4.197512 5.918545 6.633053 8.117123 3.906106 5.438581
## New Jersey 7.322902 5.684491 5.511662 7.277510 7.174625 4.429281
## New Mexico 4.954748 7.226178 5.598018 8.600500 4.922386 6.305446
## New York 8.653921 5.998749 5.759845 7.321072 8.622720 5.688592
## North Carolina 8.318375 5.926952 6.498103 7.536111 8.266676 6.082835
## North Dakota 8.687247 10.180302 9.719807 11.592308 8.419410 9.755559
## Ohio 6.305190 5.564127 4.262804 7.867264 6.236120 4.150500
## Oklahoma 5.906544 6.749317 5.648108 8.255040 6.144165 3.650849
## Oregon 6.179472 4.260792 6.008431 8.276947 5.710069 5.379701
## Pennsylvania 8.723327 7.308986 5.226836 8.828539 8.773149 6.236633
## Rhode Island 6.075385 5.229568 6.347943 8.483404 5.897447 5.567495
## South Carolina 9.216310 5.944236 7.397568 9.513635 9.112723 7.548536
## South Dakota 0.000000 7.806621 7.928437 8.557163 1.265816 6.615854
## Tennessee 7.806621 0.000000 5.845713 8.210351 7.381379 5.820073
## Texas 7.928437 5.845713 0.000000 7.716839 7.691491 5.240816
## Utah 8.557163 8.210351 7.716839 0.000000 8.793144 7.945931
## Vermont 1.265816 7.381379 7.691491 8.793144 0.000000 6.566671
## Virginia 6.615854 5.820073 5.240816 7.945931 6.566671 0.000000
## Washington 6.949806 5.222686 6.022337 6.209611 7.058193 5.543376
## West Virginia 3.798077 7.422068 7.870934 9.315837 3.812299 6.841551
## Wisconsin 6.351325 6.953639 5.190576 7.841146 6.540098 6.051127
## Wyoming 5.196751 6.652550 6.854230 6.708951 5.648347 6.521503
## Grand Total 7.977880 5.343531 4.025021 7.504707 7.865734 5.041671
## Washington West Virginia Wisconsin Wyoming Grand Total
## Alabama 5.716118 4.407156 6.120516 4.915825 6.218044
## Alaska 7.197493 7.237112 6.813791 6.411280 6.649416
## Alberta 7.648839 4.366555 7.019624 6.064700 7.984547
## Arizona 6.318643 6.781851 5.826823 7.182683 4.274130
## Arkansas 5.974328 4.848998 5.454567 5.037459 6.983158
## Armed Forces 5.627650 4.866620 5.995199 4.899935 7.271430
## California 6.853838 8.845652 6.370484 7.770176 2.442488
## Colorado 6.057213 8.273067 7.417557 7.430232 4.109117
## Connecticut 5.590082 5.056785 6.862335 5.426891 5.414111
## Delaware 6.302715 7.814470 7.082930 6.325067 7.635680
## Florida 4.921293 7.831506 5.833695 6.679687 3.667190
## Georgia 5.142458 5.634109 6.279280 5.185658 5.089513
## Hawaii 8.710108 7.711825 7.694510 7.762876 7.333753
## Idaho 6.069777 6.437182 5.308922 6.195199 6.373841
## Illinois 7.090325 8.037606 6.725349 6.934846 5.266276
## Indiana 3.830936 6.165578 5.284446 4.578402 4.921929
## Iowa 6.664780 6.860840 6.245025 6.896238 5.891074
## Kansas 6.329396 7.711189 7.953246 8.005924 7.772135
## Kentucky 5.919382 6.070705 6.097142 6.064219 6.443837
## Louisiana 5.562652 5.818086 5.311139 5.393941 5.507967
## Maine 6.613086 5.441244 5.189702 5.563723 6.691132
## Maryland 7.850963 9.255390 5.931201 8.299394 5.075635
## Massachusetts 5.675188 7.029111 5.924734 6.739440 4.526745
## Michigan 5.106184 6.093132 6.477349 6.319361 5.275256
## Minnesota 5.338240 7.228503 5.868447 6.656422 5.802195
## Mississippi 6.103148 4.219397 6.167304 3.849856 7.003535
## Missouri 5.563479 6.275096 4.845933 5.044458 5.443779
## Montana 5.735890 5.100971 5.675933 4.719607 7.067734
## Nebraska 7.012228 7.654238 7.611519 8.279431 6.657441
## Nevada 6.296989 5.875271 4.729871 4.955522 6.891992
## New Hampshire 6.319814 4.562432 5.810459 5.926614 6.812184
## New Jersey 5.592976 7.293378 6.648407 6.706337 4.143404
## New Mexico 6.475412 6.091679 6.707210 5.938386 6.228958
## New York 5.590682 7.720694 6.417604 7.414808 4.495561
## North Carolina 5.873186 8.382340 7.463045 7.071621 5.174696
## North Dakota 9.970457 8.910264 8.903015 8.768103 10.201884
## Ohio 5.567255 5.714675 5.390976 6.237973 4.585300
## Oklahoma 6.613965 6.108545 5.011600 6.270546 5.864088
## Oregon 5.105833 6.173761 6.490776 6.298179 5.657728
## Pennsylvania 6.394647 8.711816 7.253764 7.983332 4.410200
## Rhode Island 5.228611 6.451735 6.937719 5.501689 6.750076
## South Carolina 7.262601 7.613307 7.508077 8.420822 6.276222
## South Dakota 6.949806 3.798077 6.351325 5.196751 7.977880
## Tennessee 5.222686 7.422068 6.953639 6.652550 5.343531
## Texas 6.022337 7.870934 5.190576 6.854230 4.025021
## Utah 6.209611 9.315837 7.841146 6.708951 7.504707
## Vermont 7.058193 3.812299 6.540098 5.648347 7.865734
## Virginia 5.543376 6.841551 6.051127 6.521503 5.041671
## Washington 0.000000 7.218800 6.229651 5.286578 5.456135
## West Virginia 7.218800 0.000000 7.302107 5.788025 7.801763
## Wisconsin 6.229651 7.302107 0.000000 5.756116 5.973850
## Wyoming 5.286578 5.788025 5.756116 0.000000 6.981136
## Grand Total 5.456135 7.801763 5.973850 6.981136 0.000000
clusterdata<-hclust(dm,method="average")
plot(clusterdata, hang=-1, cex=0.7, main="Average Linkage Cluster")
#the cluster does not give too much insight at the first look.
dm1<-dist(datanew,method="manhattan")
## Warning in dist(datanew, method = "manhattan"): NAs introduced by coercion
#using the euclidean method of calculating distance.
as.matrix(dm1)
## Alabama Alaska Alberta Arizona Arkansas Armed Forces
## Alabama 0.00000 20.31159 18.976128 20.03722 11.253086 16.669843
## Alaska 20.31159 0.00000 17.328556 24.46068 20.615944 19.769633
## Alberta 18.97613 17.32856 0.000000 29.29593 12.318433 9.851319
## Arizona 20.03722 24.46068 29.295931 0.00000 25.425958 24.853712
## Arkansas 11.25309 20.61594 12.318433 25.42596 0.000000 9.305616
## Armed Forces 16.66984 19.76963 9.851319 24.85371 9.305616 0.000000
## California 27.83711 27.85786 37.419206 16.49585 30.984383 33.544855
## Colorado 23.98191 22.10908 32.711078 21.53585 27.440321 28.944315
## Connecticut 16.59170 20.85104 21.684465 20.45611 19.107739 17.997968
## Delaware 21.41439 18.63402 18.290272 28.98330 20.883415 17.326531
## Florida 21.38199 29.47949 34.584032 19.08875 25.886872 27.480478
## Georgia 14.89713 24.34487 19.546543 18.49043 20.213409 17.798748
## Hawaii 20.51719 21.50021 21.158729 28.31150 20.665464 20.684987
## Idaho 16.62003 13.80018 18.526529 21.55902 16.943322 14.955615
## Illinois 18.12264 27.61557 33.527983 22.61051 24.888633 26.606480
## Indiana 19.19856 20.02672 23.152353 16.00733 19.631145 19.025244
## Iowa 21.07542 25.33797 20.169170 22.45496 20.883869 16.025238
## Kansas 19.04476 25.42955 18.926510 25.67269 19.805012 16.278450
## Kentucky 13.68269 18.17608 18.049273 23.47098 15.675881 15.396904
## Louisiana 13.72988 21.21427 25.403679 17.37079 17.110150 20.115501
## Maine 16.59319 14.06942 11.369237 22.18379 15.536066 17.236455
## Maryland 27.28224 29.61818 37.595864 22.02927 33.385943 31.641413
## Massachusetts 16.94373 22.27054 29.937018 12.98014 23.747205 23.945520
## Michigan 16.42389 22.97566 24.959743 18.19643 19.105590 24.695096
## Minnesota 15.20893 26.63239 28.038975 19.35506 16.909497 18.991979
## Mississippi 10.86045 13.64060 12.723235 25.38104 11.821992 14.225640
## Missouri 11.24909 23.17651 25.297653 18.38342 16.582356 20.797560
## Montana 14.57501 10.29458 10.726289 25.03126 12.055906 9.762548
## Nebraska 20.42491 24.40204 19.105831 22.87440 19.777661 19.384824
## Nevada 16.86483 23.25291 14.894116 24.87526 14.861262 13.497930
## New Hampshire 11.19578 19.60041 12.830140 23.67208 8.775531 11.356880
## New Jersey 24.50448 28.79231 28.160784 15.49387 24.696489 24.433414
## New Mexico 17.22819 21.86912 17.350830 27.60650 15.746460 17.239201
## New York 22.17275 31.87838 35.904317 18.90562 27.464108 29.930044
## North Carolina 23.82039 27.87010 32.145508 20.48682 25.990708 28.039401
## North Dakota 26.79011 20.43800 15.872132 34.48396 16.864214 16.934285
## Ohio 16.19335 24.08539 25.341332 13.09612 20.804178 21.606122
## Oklahoma 15.64526 22.95873 20.208620 17.10533 20.148455 16.787325
## Oregon 14.71912 23.65355 23.250168 20.95224 13.683801 17.614876
## Pennsylvania 27.42519 24.27405 34.086967 18.62427 31.462818 30.945841
## Rhode Island 11.98033 22.59860 18.757365 26.62247 15.724123 13.501457
## South Carolina 21.36749 29.71385 35.874570 16.51613 26.213861 27.686003
## South Dakota 15.89104 17.64829 3.085087 30.87204 9.233346 6.766233
## Tennessee 14.93753 26.36773 31.085393 23.43490 19.555891 22.618587
## Texas 22.00008 27.32075 33.432055 17.12330 25.463996 26.886259
## Utah 28.36697 30.13563 27.382559 29.15756 26.364776 19.700857
## Vermont 14.90946 19.45909 4.066663 30.32046 8.251770 9.256787
## Virginia 16.15828 22.15049 22.245499 12.01769 20.438974 18.161788
## Washington 19.72309 26.50825 28.406444 23.44163 19.667529 19.228926
## West Virginia 13.35671 20.93987 8.681979 26.67069 12.935840 11.724147
## Wisconsin 19.00884 24.16372 23.290581 22.49466 16.917229 18.367402
## Wyoming 14.82612 17.59521 16.294859 28.29545 12.111368 12.173483
## Grand Total 24.97941 27.88030 36.722376 15.50024 29.868455 31.835936
## California Colorado Connecticut Delaware Florida Georgia
## Alabama 27.837112 23.98191 16.59170 21.41439 21.38199 14.89713
## Alaska 27.857857 22.10908 20.85104 18.63402 29.47949 24.34487
## Alberta 37.419206 32.71108 21.68446 18.29027 34.58403 19.54654
## Arizona 16.495854 21.53585 20.45611 28.98330 19.08875 18.49043
## Arkansas 30.984383 27.44032 19.10774 20.88342 25.88687 20.21341
## Armed Forces 33.544855 28.94432 17.99797 17.32653 27.48048 17.79875
## California 0.000000 17.80415 24.05169 32.19899 14.48961 19.71631
## Colorado 17.804149 0.00000 17.85917 31.52071 19.34793 18.24462
## Connecticut 24.051692 17.85917 0.00000 23.20782 20.45297 18.80308
## Delaware 32.198987 31.52071 23.20782 0.00000 25.35557 25.92145
## Florida 14.489607 19.34793 20.45297 25.35557 0.00000 20.18585
## Georgia 19.716307 18.24462 18.80308 25.92145 20.18585 0.00000
## Hawaii 31.249971 25.85312 20.76613 28.03228 33.91679 22.97599
## Idaho 27.313412 22.53185 21.40351 19.66853 23.84919 18.47902
## Illinois 19.656711 23.49202 22.74554 28.58156 21.38261 21.09052
## Indiana 18.352940 17.62953 15.38526 20.70050 13.72204 16.07314
## Iowa 25.346863 24.66780 17.94506 21.11135 17.99378 19.21283
## Kansas 33.614074 24.62123 21.86597 21.96788 26.12555 21.16920
## Kentucky 27.427301 21.58531 19.11506 19.34188 22.93777 16.99053
## Louisiana 25.174249 24.99546 16.89411 23.62508 17.69450 20.93653
## Maine 31.085668 26.73773 23.37173 18.72852 28.34321 18.85956
## Maryland 19.436443 26.30559 28.90944 32.09412 27.65922 26.66943
## Massachusetts 17.890191 22.02160 22.41205 28.84306 18.83701 16.67303
## Michigan 23.583510 24.73167 19.92087 25.10644 15.57280 19.55239
## Minnesota 24.021632 23.39793 22.05746 29.20504 16.96736 16.51942
## Mississippi 33.077882 26.89285 18.73656 16.85547 25.66360 19.32683
## Missouri 25.373026 25.72865 21.31172 24.71223 18.76106 18.55704
## Montana 32.108878 26.49027 18.13859 8.97311 25.93551 20.42840
## Nebraska 29.885913 25.34348 26.89710 28.96046 25.18657 16.28852
## Nevada 31.028628 30.03513 21.99694 17.21436 26.80011 19.39795
## New Hampshire 29.466107 25.01625 13.93998 17.84909 23.52161 19.62448
## New Jersey 17.338210 21.51039 19.87881 26.80485 10.96405 17.16194
## New Mexico 31.256783 18.74357 20.78455 21.10924 27.51726 17.06673
## New York 16.486956 22.95580 22.16525 28.61039 14.74332 21.09924
## North Carolina 24.211170 21.35864 20.09060 30.34934 15.49093 23.70587
## North Dakota 42.690181 39.52857 28.11173 23.90885 38.57023 31.97686
## Ohio 18.622580 20.22628 21.78695 25.50626 14.70132 12.94288
## Oklahoma 23.646301 22.76188 20.55220 19.40093 20.33589 14.10231
## Oregon 25.844064 22.42428 15.36555 23.53970 21.36216 19.87207
## Pennsylvania 19.776062 14.28653 23.65021 30.70528 19.34592 23.61336
## Rhode Island 30.898150 25.19563 19.74667 20.86518 22.28590 17.27597
## South Carolina 26.786422 31.04362 25.74181 33.05805 22.33636 28.10998
## South Dakota 38.940838 32.56843 20.61908 15.20519 32.84385 21.12265
## Tennessee 24.522614 23.96986 22.19956 27.67095 14.95354 20.32039
## Texas 16.967069 14.88262 21.63475 30.20784 16.06418 19.56021
## Utah 30.731340 29.26040 20.35318 23.16074 22.94255 24.05124
## Vermont 37.959261 31.58686 18.12852 17.01598 31.86227 21.34156
## Virginia 20.817065 17.70627 18.30343 21.79675 17.96680 12.89627
## Washington 24.107047 20.01224 18.22826 23.04260 16.26723 16.54781
## West Virginia 37.968529 32.20319 17.20112 19.18806 31.94516 19.52659
## Wisconsin 24.715309 26.57896 22.80601 22.52253 21.64806 20.96400
## Wyoming 31.297319 26.53762 17.64555 18.61169 24.87123 18.44276
## Grand Total 9.547551 13.78615 20.24311 31.04183 12.20837 19.11311
## Hawaii Idaho Illinois Indiana Iowa Kansas
## Alabama 20.51719 16.620029 18.12264 19.19856 21.07542 19.04476
## Alaska 21.50021 13.800182 27.61557 20.02672 25.33797 25.42955
## Alberta 21.15873 18.526529 33.52798 23.15235 20.16917 18.92651
## Arizona 28.31150 21.559023 22.61051 16.00733 22.45496 25.67269
## Arkansas 20.66546 16.943322 24.88863 19.63114 20.88387 19.80501
## Armed Forces 20.68499 14.955615 26.60648 19.02524 16.02524 16.27845
## California 31.24997 27.313412 19.65671 18.35294 25.34686 33.61407
## Colorado 25.85312 22.531852 23.49202 17.62953 24.66780 24.62123
## Connecticut 20.76613 21.403506 22.74554 15.38526 17.94506 21.86597
## Delaware 28.03228 19.668532 28.58156 20.70050 21.11135 21.96788
## Florida 33.91679 23.849191 21.38261 13.72204 17.99378 26.12555
## Georgia 22.97599 18.479015 21.09052 16.07314 19.21283 21.16920
## Hawaii 0.00000 21.255773 30.11163 26.81830 23.22623 21.80665
## Idaho 21.25577 0.000000 21.24579 17.78627 16.54876 18.97211
## Illinois 30.11163 21.245787 0.00000 19.28164 23.57934 28.41961
## Indiana 26.81830 17.786275 19.28164 0.00000 16.39992 20.13191
## Iowa 23.22623 16.548765 23.57934 16.39992 0.00000 19.67928
## Kansas 21.80665 18.972112 28.41961 20.13191 19.67928 0.00000
## Kentucky 19.01004 5.813247 22.29605 15.57944 15.62478 18.16852
## Louisiana 28.83174 21.665863 20.12429 16.45617 21.88322 26.42722
## Maine 21.81556 13.379910 27.21294 19.27823 21.43321 16.30213
## Maryland 34.42399 27.686414 18.29962 26.65376 29.59102 33.86820
## Massachusetts 28.96748 20.636658 25.17128 19.19981 23.93183 29.72997
## Michigan 34.23983 23.267377 25.76463 15.53368 25.70222 29.19954
## Minnesota 30.16487 18.665751 20.91146 17.72711 22.99515 25.48711
## Mississippi 24.51224 13.360119 23.43077 17.51969 22.66632 20.57306
## Missouri 24.08812 18.471077 20.20916 19.07509 22.35687 23.59208
## Montana 20.32269 10.973600 24.66825 15.89244 17.00375 16.64658
## Nebraska 25.70911 18.338105 32.86218 22.94511 25.07976 22.55969
## Nevada 19.14417 22.682092 24.93341 20.52238 20.81337 15.96309
## New Hampshire 16.58246 15.868859 21.52054 15.91823 14.96273 15.86129
## New Jersey 35.87518 25.826009 25.86952 14.49820 19.83755 27.63810
## New Mexico 22.01889 20.676499 26.08672 24.05194 21.47296 18.70043
## New York 34.92512 24.967661 17.89718 18.56525 22.11946 28.95792
## North Carolina 31.80336 26.086674 29.57829 18.28417 22.82181 24.44242
## North Dakota 28.06300 19.709513 34.15768 27.47922 27.04154 27.90761
## Ohio 27.35013 18.688207 22.46850 14.95993 19.14530 20.63981
## Oklahoma 18.07430 17.390940 22.02276 17.80649 16.84445 16.10874
## Oregon 21.11336 21.550420 26.51046 17.93150 23.29999 21.06175
## Pennsylvania 33.26615 25.087889 26.78512 17.79488 27.57057 28.75057
## Rhode Island 26.03658 18.386104 26.33174 19.94497 22.73166 19.85495
## South Carolina 31.55208 25.901139 24.07543 21.71202 25.05188 30.69713
## South Dakota 19.58262 15.446663 30.44290 22.79963 20.20014 15.84142
## Tennessee 28.08262 19.216529 21.23572 18.36287 22.50048 28.25386
## Texas 29.79658 20.637834 20.90209 17.72862 22.18526 26.93913
## Utah 31.32646 24.562237 29.11573 15.06359 16.42519 23.31042
## Vermont 19.88444 16.051755 31.05321 23.40995 19.30147 17.65222
## Virginia 23.95367 15.885167 24.62242 17.58760 17.33971 17.85940
## Washington 31.90381 20.869136 23.04593 11.91217 22.59049 23.21125
## West Virginia 21.77614 18.733029 27.85058 21.87169 21.16662 19.54392
## Wisconsin 23.98103 16.837189 19.10185 18.66048 18.30438 21.06126
## Wyoming 22.06156 17.616504 21.21878 16.43106 23.07958 22.75935
## Grand Total 32.22043 26.009177 19.07237 17.52780 25.22992 30.23127
## Kentucky Louisiana Maine Maryland Massachusetts
## Alabama 13.682690 13.729880 16.59319 27.28224 16.94373
## Alaska 18.176085 21.214267 14.06942 29.61818 22.27054
## Alberta 18.049273 25.403679 11.36924 37.59586 29.93702
## Arizona 23.470977 17.370789 22.18379 22.02927 12.98014
## Arkansas 15.675881 17.110150 15.53607 33.38594 23.74721
## Armed Forces 15.396904 20.115501 17.23645 31.64141 23.94552
## California 27.427301 25.174249 31.08567 19.43644 17.89019
## Colorado 21.585310 24.995458 26.73773 26.30559 22.02160
## Connecticut 19.115065 16.894112 23.37173 28.90944 22.41205
## Delaware 19.341883 23.625079 18.72852 32.09412 28.84306
## Florida 22.937768 17.694500 28.34321 27.65922 18.83701
## Georgia 16.990526 20.936534 18.85956 26.66943 16.67303
## Hawaii 19.010037 28.831739 21.81556 34.42399 28.96748
## Idaho 5.813247 21.665863 13.37991 27.68641 20.63666
## Illinois 22.296045 20.124292 27.21294 18.29962 25.17128
## Indiana 15.579444 16.456169 19.27823 26.65376 19.19981
## Iowa 15.624784 21.883219 21.43321 29.59102 23.93183
## Kansas 18.168521 26.427221 16.30213 33.86820 29.72997
## Kentucky 0.000000 24.167575 16.13191 30.39646 22.49108
## Louisiana 24.167575 0.000000 22.66669 27.34237 18.19219
## Maine 16.131907 22.666694 0.00000 28.97027 24.01426
## Maryland 30.396461 27.342371 28.97027 0.00000 22.28551
## Massachusetts 22.491077 18.192187 24.01426 22.28551 0.00000
## Michigan 22.069566 15.695216 22.13798 30.19639 16.34396
## Minnesota 20.655857 13.562278 23.70820 27.46184 18.06321
## Mississippi 14.216775 15.807413 13.39877 31.23475 22.12885
## Missouri 19.634419 9.886958 19.76804 25.58292 17.57096
## Montana 11.910478 17.559720 12.11758 32.00454 24.29394
## Nebraska 18.020195 24.918190 19.89253 35.90900 22.00145
## Nevada 21.878500 17.350608 17.51629 26.64722 25.89393
## New Hampshire 13.158015 16.290078 17.75728 29.68881 25.30187
## New Jersey 25.000897 18.938337 26.00960 29.55171 19.89498
## New Mexico 19.872907 20.936821 17.48397 30.95257 26.97997
## New York 24.970461 24.183245 28.50320 22.36703 19.74489
## North Carolina 26.266971 20.101937 26.60087 32.77478 21.02880
## North Dakota 23.264790 27.163363 16.95333 39.55659 34.41559
## Ohio 19.877904 13.345140 19.84673 23.89650 13.37501
## Oklahoma 16.050790 20.735301 18.51293 23.79762 17.64300
## Oregon 18.302189 16.079873 22.88313 28.64533 22.12396
## Pennsylvania 24.784569 26.217482 27.31149 25.38533 19.18344
## Rhode Island 17.949517 17.650260 21.57964 30.97822 21.01274
## South Carolina 26.108441 16.615363 29.14053 30.06218 21.47217
## South Dakota 14.964186 22.318592 11.83538 36.50430 29.94867
## Tennessee 17.456352 18.542241 27.14500 32.31315 19.94648
## Texas 21.609298 18.694663 24.59627 21.74740 19.87798
## Utah 23.655848 24.392268 27.43905 37.02819 29.97592
## Vermont 15.574500 21.337016 13.64617 37.11461 28.96709
## Virginia 16.092930 21.361001 18.82310 26.00000 15.75056
## Washington 19.999906 18.608655 25.60910 28.23606 20.61270
## West Virginia 17.469507 20.011711 15.29046 33.81117 27.14287
## Wisconsin 17.965180 19.106925 17.75196 19.44736 22.57782
## Wyoming 17.831940 18.569221 18.06286 31.05164 24.10689
## Grand Total 26.376060 21.326594 28.68414 18.95118 15.97344
## Michigan Minnesota Mississippi Missouri Montana Nebraska
## Alabama 16.42389 15.20893 10.860455 11.249085 14.575009 20.42491
## Alaska 22.97566 26.63239 13.640599 23.176513 10.294580 24.40204
## Alberta 24.95974 28.03898 12.723235 25.297653 10.726289 19.10583
## Arizona 18.19643 19.35506 25.381037 18.383416 25.031256 22.87440
## Arkansas 19.10559 16.90950 11.821992 16.582356 12.055906 19.77766
## Armed Forces 24.69510 18.99198 14.225640 20.797560 9.762548 19.38482
## California 23.58351 24.02163 33.077882 25.373026 32.108878 29.88591
## Colorado 24.73167 23.39793 26.892855 25.728652 26.490270 25.34348
## Connecticut 19.92087 22.05746 18.736565 21.311721 18.138591 26.89710
## Delaware 25.10644 29.20504 16.855471 24.712228 8.973110 28.96046
## Florida 15.57280 16.96736 25.663597 18.761056 25.935511 25.18657
## Georgia 19.55239 16.51942 19.326835 18.557037 20.428402 16.28852
## Hawaii 34.23983 30.16487 24.512238 24.088120 20.322691 25.70911
## Idaho 23.26738 18.66575 13.360119 18.471077 10.973600 18.33810
## Illinois 25.76463 20.91146 23.430774 20.209162 24.668246 32.86218
## Indiana 15.53368 17.72711 17.519693 19.075089 15.892443 22.94511
## Iowa 25.70222 22.99515 22.666320 22.356874 17.003749 25.07976
## Kansas 29.19954 25.48711 20.573064 23.592079 16.646583 22.55969
## Kentucky 22.06957 20.65586 14.216775 19.634419 11.910478 18.02020
## Louisiana 15.69522 13.56228 15.807413 9.886958 17.559720 24.91819
## Maine 22.13798 23.70820 13.398766 19.768037 12.117584 19.89253
## Maryland 30.19639 27.46184 31.234748 25.582918 32.004543 35.90900
## Massachusetts 16.34396 18.06321 22.128845 17.570957 24.293935 22.00145
## Michigan 0.00000 18.97307 18.330055 17.295669 21.250802 22.06846
## Minnesota 18.97307 0.00000 19.006677 11.670552 22.020667 21.81826
## Mississippi 18.33006 19.00668 0.000000 14.367863 8.772148 23.57318
## Missouri 17.29567 11.67055 14.367863 0.000000 19.575707 22.46299
## Montana 21.25080 22.02067 8.772148 19.575707 0.000000 19.98735
## Nebraska 22.06846 21.81826 23.573181 22.462987 19.987350 0.00000
## Nevada 24.48795 23.23577 16.496898 17.056969 14.332849 24.85721
## New Hampshire 20.67505 18.13615 13.070988 16.715141 10.249421 20.03363
## New Jersey 15.59395 18.93374 24.129539 22.048016 25.902479 20.62532
## New Mexico 25.59350 20.41367 16.428519 20.433583 14.609112 22.84171
## New York 21.03085 21.11314 29.107532 23.121281 29.388208 31.44769
## North Carolina 20.07704 24.48891 23.471044 19.177786 26.981741 27.53513
## North Dakota 32.23846 30.56713 17.926990 29.167290 15.081344 31.33164
## Ohio 15.82221 15.60925 20.362188 15.478290 20.309250 17.22541
## Oklahoma 22.11118 20.66654 18.410159 17.488058 15.585389 19.55209
## Oregon 17.83384 14.50397 19.307735 14.576933 17.763087 20.30191
## Pennsylvania 21.58466 25.84174 28.272757 24.009629 28.014580 27.33394
## Rhode Island 18.68117 17.56240 14.578858 16.325355 15.664008 20.05465
## South Carolina 23.48297 18.23607 26.448768 16.984732 27.277547 31.23489
## South Dakota 25.22840 24.95389 9.638148 22.212566 7.641202 20.68194
## Tennessee 17.04879 12.99946 20.943554 16.410825 20.887768 18.98002
## Texas 19.90416 20.29458 26.385003 20.489550 25.783776 25.74539
## Utah 28.72772 26.70017 25.604083 27.851707 20.196540 31.74879
## Vermont 24.24683 23.97231 10.248461 21.230990 9.452000 20.90085
## Virginia 20.21054 19.16671 21.244153 17.880015 19.179754 18.44795
## Washington 17.97445 17.11091 20.889671 20.958774 18.794477 23.40532
## West Virginia 21.45402 23.97719 11.356288 22.411339 11.902261 23.24661
## Wisconsin 21.79468 19.33824 19.895718 14.353877 18.377492 25.70756
## Wyoming 21.03603 21.19326 10.406967 18.927989 12.146991 26.38035
## Grand Total 19.21670 20.56181 30.550270 21.825512 31.204740 27.57631
## Nevada New Hampshire New Jersey New Mexico New York
## Alabama 16.86483 11.195783 24.50448 17.22819 22.17275
## Alaska 23.25291 19.600407 28.79231 21.86912 31.87838
## Alberta 14.89412 12.830140 28.16078 17.35083 35.90432
## Arizona 24.87526 23.672080 15.49387 27.60650 18.90562
## Arkansas 14.86126 8.775531 24.69649 15.74646 27.46411
## Armed Forces 13.49793 11.356880 24.43341 17.23920 29.93004
## California 31.02863 29.466107 17.33821 31.25678 16.48696
## Colorado 30.03513 25.016249 21.51039 18.74357 22.95580
## Connecticut 21.99694 13.939978 19.87881 20.78455 22.16525
## Delaware 17.21436 17.849090 26.80485 21.10924 28.61039
## Florida 26.80011 23.521611 10.96405 27.51726 14.74332
## Georgia 19.39795 19.624475 17.16194 17.06673 21.09924
## Hawaii 19.14417 16.582460 35.87518 22.01889 34.92512
## Idaho 22.68209 15.868859 25.82601 20.67650 24.96766
## Illinois 24.93341 21.520535 25.86952 26.08672 17.89718
## Indiana 20.52238 15.918227 14.49820 24.05194 18.56525
## Iowa 20.81337 14.962728 19.83755 21.47296 22.11946
## Kansas 15.96309 15.861287 27.63810 18.70043 28.95792
## Kentucky 21.87850 13.158015 25.00090 19.87291 24.97046
## Louisiana 17.35061 16.290078 18.93834 20.93682 24.18324
## Maine 17.51629 17.757285 26.00960 17.48397 28.50320
## Maryland 26.64722 29.688806 29.55171 30.95257 22.36703
## Massachusetts 25.89393 25.301872 19.89498 26.97997 19.74489
## Michigan 24.48795 20.675048 15.59395 25.59350 21.03085
## Minnesota 23.23577 18.136148 18.93374 20.41367 21.11314
## Mississippi 16.49690 13.070988 24.12954 16.42852 29.10753
## Missouri 17.05697 16.715141 22.04802 20.43358 23.12128
## Montana 14.33285 10.249421 25.90248 14.60911 29.38821
## Nebraska 24.85721 20.033634 20.62532 22.84171 31.44769
## Nevada 0.00000 12.602787 26.65911 15.39728 27.84806
## New Hampshire 12.60279 0.000000 25.09073 16.49895 25.54721
## New Jersey 26.65911 25.090729 0.00000 26.95692 18.74886
## New Mexico 15.39728 16.498955 26.95692 0.00000 31.83203
## New York 27.84806 25.547209 18.74886 31.83203 0.00000
## North Carolina 26.74396 26.485459 17.28451 27.37849 23.78512
## North Dakota 24.35782 19.411240 36.17295 25.03452 40.97641
## Ohio 19.60470 20.267176 17.28569 18.73289 18.65510
## Oklahoma 12.44683 14.008411 22.71931 17.29945 22.38419
## Oregon 18.83432 12.255883 23.40179 18.15087 26.16148
## Pennsylvania 29.51528 27.301017 19.58123 25.92925 25.74294
## Rhode Island 16.50944 16.586046 25.33159 19.20174 27.30530
## South Carolina 26.77426 24.716460 24.79204 30.63842 23.36747
## South Dakota 11.80903 11.254031 29.73689 14.26574 35.29226
## Tennessee 29.15476 20.512028 19.08787 27.10566 22.90558
## Texas 24.84743 24.169618 19.07810 22.09443 19.24495
## Utah 22.21335 22.398358 24.68063 26.28197 26.06734
## Vermont 13.61983 10.355367 28.75532 14.48465 34.31069
## Virginia 20.66282 17.386031 15.83488 22.40265 18.08918
## Washington 23.19871 20.146302 17.44250 24.86067 21.65884
## West Virginia 15.51152 11.787126 28.78391 17.75708 29.69537
## Wisconsin 13.16067 15.004906 24.67580 20.91936 21.96888
## Wyoming 14.48957 16.128630 24.85597 19.24998 25.45214
## Grand Total 30.17881 28.208958 14.35124 26.68917 14.90540
## North Carolina North Dakota Ohio Oklahoma Oregon
## Alabama 23.82039 26.79011 16.19335 15.64526 14.71912
## Alaska 27.87010 20.43800 24.08539 22.95873 23.65355
## Alberta 32.14551 15.87213 25.34133 20.20862 23.25017
## Arizona 20.48682 34.48396 13.09612 17.10533 20.95224
## Arkansas 25.99071 16.86421 20.80418 20.14846 13.68380
## Armed Forces 28.03940 16.93429 21.60612 16.78732 17.61488
## California 24.21117 42.69018 18.62258 23.64630 25.84406
## Colorado 21.35864 39.52857 20.22628 22.76188 22.42428
## Connecticut 20.09060 28.11173 21.78695 20.55220 15.36555
## Delaware 30.34934 23.90885 25.50626 19.40093 23.53970
## Florida 15.49093 38.57023 14.70132 20.33589 21.36216
## Georgia 23.70587 31.97686 12.94288 14.10231 19.87207
## Hawaii 31.80336 28.06300 27.35013 18.07430 21.11336
## Idaho 26.08667 19.70951 18.68821 17.39094 21.55042
## Illinois 29.57829 34.15768 22.46850 22.02276 26.51046
## Indiana 18.28417 27.47922 14.95993 17.80649 17.93150
## Iowa 22.82181 27.04154 19.14530 16.84445 23.29999
## Kansas 24.44242 27.90761 20.63981 16.10874 21.06175
## Kentucky 26.26697 23.26479 19.87790 16.05079 18.30219
## Louisiana 20.10194 27.16336 13.34514 20.73530 16.07987
## Maine 26.60087 16.95333 19.84673 18.51293 22.88313
## Maryland 32.77478 39.55659 23.89650 23.79762 28.64533
## Massachusetts 21.02880 34.41559 13.37501 17.64300 22.12396
## Michigan 20.07704 32.23846 15.82221 22.11118 17.83384
## Minnesota 24.48891 30.56713 15.60925 20.66654 14.50397
## Mississippi 23.47104 17.92699 20.36219 18.41016 19.30773
## Missouri 19.17779 29.16729 15.47829 17.48806 14.57693
## Montana 26.98174 15.08134 20.30925 15.58539 17.76309
## Nebraska 27.53513 31.33164 17.22541 19.55209 20.30191
## Nevada 26.74396 24.35782 19.60470 12.44683 18.83432
## New Hampshire 26.48546 19.41124 20.26718 14.00841 12.25588
## New Jersey 17.28451 36.17295 17.28569 22.71931 23.40179
## New Mexico 27.37849 25.03452 18.73289 17.29945 18.15087
## New York 23.78512 40.97641 18.65510 22.38419 26.16148
## North Carolina 0.00000 38.31772 18.60779 24.11510 23.72566
## North Dakota 38.31772 0.00000 31.06861 28.99744 30.54802
## Ohio 18.60779 31.06861 0.00000 12.67299 19.05748
## Oklahoma 24.11510 28.99744 12.67299 0.00000 19.66210
## Oregon 23.72566 30.54802 19.05748 19.66210 0.00000
## Pennsylvania 20.77417 39.29046 22.11209 23.15760 26.31792
## Rhode Island 24.83108 29.96830 19.91441 19.60264 14.62957
## South Carolina 20.28870 35.69142 18.27370 24.50275 21.90069
## South Dakota 31.35186 14.29602 24.41830 18.53653 20.16508
## Tennessee 22.12095 33.69589 20.15045 24.00527 15.66301
## Texas 21.47042 34.95737 14.92164 18.64663 22.40386
## Utah 25.94637 33.20933 25.85799 25.15568 25.11153
## Vermont 30.37029 14.59784 24.63721 20.34733 19.18350
## Virginia 19.20740 32.38027 15.35873 12.77366 18.97065
## Washington 20.41562 31.69566 20.08049 24.21716 18.30103
## West Virginia 32.49550 18.63750 21.15786 18.45666 20.34870
## Wisconsin 24.12493 23.59596 20.41626 14.89053 22.30860
## Wyoming 23.73809 20.31911 23.30401 20.32748 22.65924
## Grand Total 19.06656 41.80287 16.63770 23.27713 23.62923
## Pennsylvania Rhode Island South Carolina South Dakota
## Alabama 27.42519 11.98033 21.36749 15.891041
## Alaska 24.27405 22.59860 29.71385 17.648287
## Alberta 34.08697 18.75736 35.87457 3.085087
## Arizona 18.62427 26.62247 16.51613 30.872040
## Arkansas 31.46282 15.72412 26.21386 9.233346
## Armed Forces 30.94584 13.50146 27.68600 6.766233
## California 19.77606 30.89815 26.78642 38.940838
## Colorado 14.28653 25.19563 31.04362 32.568434
## Connecticut 23.65021 19.74667 25.74181 20.619079
## Delaware 30.70528 20.86518 33.05805 15.205185
## Florida 19.34592 22.28590 22.33636 32.843849
## Georgia 23.61336 17.27597 28.10998 21.122652
## Hawaii 33.26615 26.03658 31.55208 19.582621
## Idaho 25.08789 18.38610 25.90114 15.446663
## Illinois 26.78512 26.33174 24.07543 30.442896
## Indiana 17.79488 19.94497 21.71202 22.799632
## Iowa 27.57057 22.73166 25.05188 20.200136
## Kansas 28.75057 19.85495 30.69713 15.841424
## Kentucky 24.78457 17.94952 26.10844 14.964186
## Louisiana 26.21748 17.65026 16.61536 22.318592
## Maine 27.31149 21.57964 29.14053 11.835376
## Maryland 25.38533 30.97822 30.06218 36.504298
## Massachusetts 19.18344 21.01274 21.47217 29.948670
## Michigan 21.58466 18.68117 23.48297 25.228401
## Minnesota 25.84174 17.56240 18.23607 24.953889
## Mississippi 28.27276 14.57886 26.44877 9.638148
## Missouri 24.00963 16.32536 16.98473 22.212566
## Montana 28.01458 15.66401 27.27755 7.641202
## Nebraska 27.33394 20.05465 31.23489 20.681940
## Nevada 29.51528 16.50944 26.77426 11.809029
## New Hampshire 27.30102 16.58605 24.71646 11.254031
## New Jersey 19.58123 25.33159 24.79204 29.736893
## New Mexico 25.92925 19.20174 30.63842 14.265743
## New York 25.74294 27.30530 23.36747 35.292263
## North Carolina 20.77417 24.83108 20.28870 31.351864
## North Dakota 39.29046 29.96830 35.69142 14.296024
## Ohio 22.11209 19.91441 18.27370 24.418304
## Oklahoma 23.15760 19.60264 24.50275 18.536533
## Oregon 26.31792 14.62957 21.90069 20.165081
## Pennsylvania 0.00000 31.20766 25.39859 35.059742
## Rhode Island 31.20766 0.00000 30.55002 15.672278
## South Carolina 25.39859 30.55002 0.00000 32.789483
## South Dakota 35.05974 15.67228 32.78948 0.000000
## Tennessee 24.93321 17.31466 19.76710 28.000306
## Texas 18.33661 22.90491 25.36695 32.236074
## Utah 31.57173 24.27615 31.58471 24.297472
## Vermont 35.67005 15.37046 33.39980 2.490554
## Virginia 19.89497 18.54178 25.65974 23.821608
## Washington 22.05342 17.71249 28.03126 25.321358
## West Virginia 34.22984 18.07133 27.19259 7.105870
## Wisconsin 24.36934 21.67796 24.76939 20.205495
## Wyoming 29.39828 16.10200 29.36318 13.209772
## Grand Total 14.71537 28.56574 24.41957 37.013057
## Tennessee Texas Utah Vermont Virginia Washington
## Alabama 14.93753 22.00008 28.36697 14.909465 16.15828 19.72309
## Alaska 26.36773 27.32075 30.13563 19.459085 22.15049 26.50825
## Alberta 31.08539 33.43205 27.38256 4.066663 22.24550 28.40644
## Arizona 23.43490 17.12330 29.15756 30.320457 12.01769 23.44163
## Arkansas 19.55589 25.46400 26.36478 8.251770 20.43897 19.66753
## Armed Forces 22.61859 26.88626 19.70086 9.256787 18.16179 19.22893
## California 24.52261 16.96707 30.73134 37.959261 20.81706 24.10705
## Colorado 23.96986 14.88262 29.26040 31.586858 17.70627 20.01224
## Connecticut 22.19956 21.63475 20.35318 18.128524 18.30343 18.22826
## Delaware 27.67095 30.20784 23.16074 17.015983 21.79675 23.04260
## Florida 14.95354 16.06418 22.94255 31.862272 17.96680 16.26723
## Georgia 20.32039 19.56021 24.05124 21.341561 12.89627 16.54781
## Hawaii 28.08262 29.79658 31.32646 19.884441 23.95367 31.90381
## Idaho 19.21653 20.63783 24.56224 16.051755 15.88517 20.86914
## Illinois 21.23572 20.90209 29.11573 31.053209 24.62242 23.04593
## Indiana 18.36287 17.72862 15.06359 23.409945 17.58760 11.91217
## Iowa 22.50048 22.18526 16.42519 19.301471 17.33971 22.59049
## Kansas 28.25386 26.93913 23.31042 17.652222 17.85940 23.21125
## Kentucky 17.45635 21.60930 23.65585 15.574500 16.09293 19.99991
## Louisiana 18.54224 18.69466 24.39227 21.337016 21.36100 18.60865
## Maine 27.14500 24.59627 27.43905 13.646174 18.82310 25.60910
## Maryland 32.31315 21.74740 37.02819 37.114611 26.00000 28.23606
## Massachusetts 19.94648 19.87798 29.97592 28.967094 15.75056 20.61270
## Michigan 17.04879 19.90416 28.72772 24.246825 20.21054 17.97445
## Minnesota 12.99946 20.29458 26.70017 23.972312 19.16671 17.11091
## Mississippi 20.94355 26.38500 25.60408 10.248461 21.24415 20.88967
## Missouri 16.41083 20.48955 27.85171 21.230990 17.88002 20.95877
## Montana 20.88777 25.78378 20.19654 9.452000 19.17975 18.79448
## Nebraska 18.98002 25.74539 31.74879 20.900848 18.44795 23.40532
## Nevada 29.15476 24.84743 22.21335 13.619827 20.66282 23.19871
## New Hampshire 20.51203 24.16962 22.39836 10.355367 17.38603 20.14630
## New Jersey 19.08787 19.07810 24.68063 28.755317 15.83488 17.44250
## New Mexico 27.10566 22.09443 26.28197 14.484652 22.40265 24.86067
## New York 22.90558 19.24495 26.06734 34.310686 18.08918 21.65884
## North Carolina 22.12095 21.47042 25.94637 30.370288 19.20740 20.41562
## North Dakota 33.69589 34.95737 33.20933 14.597844 32.38027 31.69566
## Ohio 20.15045 14.92164 25.85799 24.637213 15.35873 20.08049
## Oklahoma 24.00527 18.64663 25.15568 20.347331 12.77366 24.21716
## Oregon 15.66301 22.40386 25.11153 19.183505 18.97065 18.30103
## Pennsylvania 24.93321 18.33661 31.57173 35.670055 19.89497 22.05342
## Rhode Island 17.31466 22.90491 24.27615 15.370458 18.54178 17.71249
## South Carolina 19.76710 25.36695 31.58471 33.399796 25.65974 28.03126
## South Dakota 28.00031 32.23607 24.29747 2.490554 23.82161 25.32136
## Tennessee 0.00000 19.96185 29.53419 27.018730 22.06429 16.93892
## Texas 19.96185 0.00000 29.33908 31.254498 17.60730 22.38514
## Utah 29.53419 29.33908 0.00000 24.907786 24.97453 18.16115
## Vermont 27.01873 31.25450 24.90779 0.000000 22.84003 24.33978
## Virginia 22.06429 17.60730 24.97453 22.840032 0.00000 20.14534
## Washington 16.93892 22.38514 18.16115 24.339781 20.14534 0.00000
## West Virginia 26.95640 31.53919 27.21704 7.407690 24.24968 24.40132
## Wisconsin 24.70430 18.84684 23.72038 20.815808 20.78618 22.03341
## Wyoming 21.78659 25.42904 20.49065 15.020570 22.65057 17.13217
## Grand Total 21.50378 14.32226 30.15433 36.031481 18.96896 20.38479
## West Virginia Wisconsin Wyoming Grand Total
## Alabama 13.356706 19.00884 14.82612 24.979412
## Alaska 20.939874 24.16372 17.59521 27.880298
## Alberta 8.681979 23.29058 16.29486 36.722376
## Arizona 26.670693 22.49466 28.29545 15.500243
## Arkansas 12.935840 16.91723 12.11137 29.868455
## Armed Forces 11.724147 18.36740 12.17348 31.835936
## California 37.968529 24.71531 31.29732 9.547551
## Colorado 32.203190 26.57896 26.53762 13.786153
## Connecticut 17.201120 22.80601 17.64555 20.243112
## Delaware 19.188065 22.52253 18.61169 31.041828
## Florida 31.945161 21.64806 24.87123 12.208366
## Georgia 19.526587 20.96400 18.44276 19.113110
## Hawaii 21.776137 23.98103 22.06156 32.220428
## Idaho 18.733029 16.83719 17.61650 26.009177
## Illinois 27.850578 19.10185 21.21878 19.072369
## Indiana 21.871689 18.66048 16.43106 17.527800
## Iowa 21.166618 18.30438 23.07958 25.229922
## Kansas 19.543918 21.06126 22.75935 30.231267
## Kentucky 17.469507 17.96518 17.83194 26.376060
## Louisiana 20.011711 19.10692 18.56922 21.326594
## Maine 15.290458 17.75196 18.06286 28.684144
## Maryland 33.811168 19.44736 31.05164 18.951180
## Massachusetts 27.142869 22.57782 24.10689 15.973438
## Michigan 21.454020 21.79468 21.03603 19.216696
## Minnesota 23.977188 19.33824 21.19326 20.561813
## Mississippi 11.356288 19.89572 10.40697 30.550270
## Missouri 22.411339 14.35388 18.92799 21.825512
## Montana 11.902261 18.37749 12.14699 31.204740
## Nebraska 23.246608 25.70756 26.38035 27.576315
## Nevada 15.511523 13.16067 14.48957 30.178811
## New Hampshire 11.787126 15.00491 16.12863 28.208958
## New Jersey 28.783912 24.67580 24.85597 14.351236
## New Mexico 17.757079 20.91936 19.24998 26.689173
## New York 29.695371 21.96888 25.45214 14.905399
## North Carolina 32.495496 24.12493 23.73809 19.066563
## North Dakota 18.637496 23.59596 20.31911 41.802868
## Ohio 21.157864 20.41626 23.30401 16.637702
## Oklahoma 18.456663 14.89053 20.32748 23.277135
## Oregon 20.348700 22.30860 22.65924 23.629231
## Pennsylvania 34.229843 24.36934 29.39828 14.715373
## Rhode Island 18.071329 21.67796 16.10200 28.565741
## South Carolina 27.192591 24.76939 29.36318 24.419573
## South Dakota 7.105870 20.20549 13.20977 37.013057
## Tennessee 26.956397 24.70430 21.78659 21.503781
## Texas 31.539185 18.84684 25.42904 14.322264
## Utah 27.217035 23.72038 20.49065 30.154331
## Vermont 7.407690 20.81581 15.02057 36.031481
## Virginia 24.249677 20.78618 22.65057 18.968962
## Washington 24.401322 22.03341 17.13217 20.384789
## West Virginia 0.000000 23.90799 14.35340 35.376629
## Wisconsin 23.907989 0.00000 17.58199 24.440180
## Wyoming 14.353404 17.58199 0.00000 29.403112
## Grand Total 35.376629 24.44018 29.40311 0.000000
clusterdata2<-hclust(dm1,method="average")
plot(clusterdata2, hang=-1, cex=0.7, main="Average Linkage Cluster")
#my next step is to see what are the optimum number of cluster that I can cut my data into for which I use Nbclust.
library(NbClust)
data2 <- NbClust(datascaled, distance="euclidean",min.nc=2, max.nc=12, method="average")
## *** : The Hubert index is a graphical method of determining the number of clusters.
## In the plot of Hubert index, we seek a significant knee that corresponds to a
## significant increase of the value of the measure i.e the significant peak in Hubert
## index second differences plot.
##
## *** : The D index is a graphical method of determining the number of clusters.
## In the plot of D index, we seek a significant knee (the significant peak in Dindex
## second differences plot) that corresponds to a significant increase of the value of
## the measure.
##
## *******************************************************************
## * Among all indices:
## * 9 proposed 2 as the best number of clusters
## * 2 proposed 3 as the best number of clusters
## * 1 proposed 4 as the best number of clusters
## * 2 proposed 5 as the best number of clusters
## * 1 proposed 9 as the best number of clusters
## * 2 proposed 10 as the best number of clusters
## * 7 proposed 11 as the best number of clusters
##
## ***** Conclusion *****
##
## * According to the majority rule, the best number of clusters is 2
##
##
## *******************************************************************
table(data2$Best.n[1,])
##
## 0 2 3 4 5 9 10 11
## 2 9 2 1 2 1 2 7
barplot(table(data2$Best.n[1,]),xlab="Numer of Clusters", ylab="Number of Criteria",main="Number of Clusters Chosen by 26 Criteria")
#based on the plot, it appears 8 criteria show that 2 clusters would be the best way to cluster this data set. While 7 show that 11 clusters would be ideal. Using our descrition and knowledge of the data,it seems that 2 clusters would not be of much use. So I ve gone ahead and used 11 clusters in the next step.
clusters <- cutree(clusterdata, k=11)
table(clusters)
## clusters
## 1 2 3 4 5 6 7 8 9 10 11
## 23 19 2 1 1 2 1 1 1 1 1
aggregate(data[,-1], by=list(cluster=clusters), mean)
## cluster Amethyst Aquamarine Black.Diamond Blue.Topaz Citrine
## 1 1 750.1921 1072.0755 752.2279 690.3289 678.2364
## 2 2 458.5439 492.6009 205.6404 322.4263 178.4737
## 3 3 785.8403 1035.8346 756.4167 604.5714 400.2500
## 4 4 932.5000 553.0000 0.0000 0.0000 0.0000
## 5 5 0.0000 0.0000 410.0000 0.0000 0.0000
## 6 6 1375.6806 983.0625 695.4167 773.5833 0.0000
## 7 7 538.2500 0.0000 898.0000 0.0000 0.0000
## 8 8 325.0000 0.0000 0.0000 0.0000 1060.5000
## 9 9 0.0000 0.0000 0.0000 0.0000 0.0000
## 10 10 566.0000 1059.6000 1399.0000 1374.3333 0.0000
## 11 11 1239.0000 323.0000 1398.0000 326.0000 0.0000
## Diamond Emerald Garnet Morganite Peridot Pink.Sapphire
## 1 339.6348 1358.637 650.9821 767.74235 502.6975 247.8528
## 2 218.0526 1029.699 205.1579 34.10526 143.7105 284.7368
## 3 4445.2500 1470.611 440.4333 741.00000 558.1000 1640.5000
## 4 0.0000 644.000 0.0000 0.00000 0.0000 0.0000
## 5 0.0000 2031.000 0.0000 0.00000 1400.0000 2512.0000
## 6 1738.0000 1251.493 957.7500 0.00000 706.2500 761.0000
## 7 0.0000 1413.833 0.0000 0.00000 439.0000 0.0000
## 8 0.0000 597.500 367.0000 1459.00000 650.0000 0.0000
## 9 0.0000 9962.000 0.0000 0.00000 0.0000 0.0000
## 10 0.0000 2135.250 2236.0000 2650.00000 569.5000 595.0000
## 11 0.0000 512.000 0.0000 777.50000 0.0000 0.0000
## Pink.Tourmaline Plain Ruby Sapphire SI.Diamond Tanzanite
## 1 683.0863 541.3469 1815.2820 1383.5890 810.7709 1015.8803
## 2 187.4737 135.5263 939.4718 942.3746 572.2982 653.8211
## 3 1028.0000 453.8500 1423.9048 2134.1500 894.1667 1214.6944
## 4 0.0000 0.0000 0.0000 1624.0000 0.0000 3588.0000
## 5 0.0000 0.0000 3375.0000 1802.7500 0.0000 332.0000
## 6 292.7500 419.6667 2087.0167 1382.6282 2208.5000 1037.2500
## 7 0.0000 457.0000 1210.6667 1592.0000 0.0000 0.0000
## 8 2191.0000 455.0000 1612.6000 3147.5000 589.0000 349.0000
## 9 0.0000 0.0000 0.0000 0.0000 2592.0000 1377.0000
## 10 0.0000 399.0000 3019.2500 1050.8333 1316.0000 1435.0000
## 11 0.0000 1011.0000 1048.5000 1160.0000 0.0000 1629.3333
## VS.Diamond VVS.Diamond White.Sapphire White.Topaz Grand.Total
## 1 836.0638 561.8826 428.01732 334.4657 1151.2823
## 2 207.5263 0.0000 95.77368 153.5263 998.5589
## 3 2493.1000 0.0000 391.50000 475.7500 1179.3320
## 4 1338.0000 1355.0000 460.00000 0.0000 1204.8000
## 5 0.0000 0.0000 0.00000 698.0000 1531.7500
## 6 370.0000 4662.5000 683.50000 228.6667 1284.7682
## 7 7133.0000 0.0000 0.00000 0.0000 1542.7500
## 8 0.0000 0.0000 0.00000 0.0000 1187.0000
## 9 0.0000 0.0000 0.00000 0.0000 4643.6667
## 10 0.0000 0.0000 473.00000 0.0000 1412.5778
## 11 1495.3333 0.0000 0.00000 2514.0000 1100.9600
aggregate(data[,-1], by=list(cluster=clusters), median)
## cluster Amethyst Aquamarine Black.Diamond Blue.Topaz Citrine Diamond
## 1 1 742.3333 994.3333 826.0000 575.0000 666.3333 0.00
## 2 2 388.0000 406.0000 0.0000 0.0000 0.0000 0.00
## 3 3 785.8403 1035.8346 756.4167 604.5714 400.2500 4445.25
## 4 4 932.5000 553.0000 0.0000 0.0000 0.0000 0.00
## 5 5 0.0000 0.0000 410.0000 0.0000 0.0000 0.00
## 6 6 1375.6806 983.0625 695.4167 773.5833 0.0000 1738.00
## 7 7 538.2500 0.0000 898.0000 0.0000 0.0000 0.00
## 8 8 325.0000 0.0000 0.0000 0.0000 1060.5000 0.00
## 9 9 0.0000 0.0000 0.0000 0.0000 0.0000 0.00
## 10 10 566.0000 1059.6000 1399.0000 1374.3333 0.0000 0.00
## 11 11 1239.0000 323.0000 1398.0000 326.0000 0.0000 0.00
## Emerald Garnet Morganite Peridot Pink.Sapphire Pink.Tourmaline
## 1 1388.143 536.3333 868.0 545.00 0.0 635.00
## 2 1060.000 0.0000 0.0 0.00 0.0 0.00
## 3 1470.611 440.4333 741.0 558.10 1640.5 1028.00
## 4 644.000 0.0000 0.0 0.00 0.0 0.00
## 5 2031.000 0.0000 0.0 1400.00 2512.0 0.00
## 6 1251.493 957.7500 0.0 706.25 761.0 292.75
## 7 1413.833 0.0000 0.0 439.00 0.0 0.00
## 8 597.500 367.0000 1459.0 650.00 0.0 2191.00
## 9 9962.000 0.0000 0.0 0.00 0.0 0.00
## 10 2135.250 2236.0000 2650.0 569.50 595.0 0.00
## 11 512.000 0.0000 777.5 0.00 0.0 0.00
## Plain Ruby Sapphire SI.Diamond Tanzanite VS.Diamond VVS.Diamond
## 1 575.1685 1721.979 1447.000 801.7500 1100.945 768.000 0.0
## 2 0.0000 565.000 985.000 0.0000 680.000 0.000 0.0
## 3 453.8500 1423.905 2134.150 894.1667 1214.694 2493.100 0.0
## 4 0.0000 0.000 1624.000 0.0000 3588.000 1338.000 1355.0
## 5 0.0000 3375.000 1802.750 0.0000 332.000 0.000 0.0
## 6 419.6667 2087.017 1382.628 2208.5000 1037.250 370.000 4662.5
## 7 457.0000 1210.667 1592.000 0.0000 0.000 7133.000 0.0
## 8 455.0000 1612.600 3147.500 589.0000 349.000 0.000 0.0
## 9 0.0000 0.000 0.000 2592.0000 1377.000 0.000 0.0
## 10 399.0000 3019.250 1050.833 1316.0000 1435.000 0.000 0.0
## 11 1011.0000 1048.500 1160.000 0.0000 1629.333 1495.333 0.0
## White.Sapphire White.Topaz Grand.Total
## 1 495.0 402.0000 1154.123
## 2 0.0 0.0000 1051.143
## 3 391.5 475.7500 1179.332
## 4 460.0 0.0000 1204.800
## 5 0.0 698.0000 1531.750
## 6 683.5 228.6667 1284.768
## 7 0.0 0.0000 1542.750
## 8 0.0 0.0000 1187.000
## 9 0.0 0.0000 4643.667
## 10 473.0 0.0000 1412.578
## 11 0.0 2514.0000 1100.960
plot(clusterdata, hang=-1, cex=.8,main="Average Linkage Clustering\n11 Cluster Solution")
rect.hclust(clusterdata, k=11)
c1 <- data.frame(data$State,clusters)
a<-c1$data.State[c1$clusters==1]
b<-c1$data.State[c1$clusters==2]
#we use 11 clusters to cluster the data. We also view the mean and median price of each cluster by gemstone.
# from the new dendogram it appears there are 2 main clusters we can use and further analyze. One constitutes of 25 states and 1 of 16. we view the states in these 2 clusters. It appears that the median for the 1st cluster is higher for several stones like amethyst, aquamarine, sapphire, ruby vs the 3rd cluster. Maybe we can investigate if these states are likely to spend more on fine jewelry vs the states in cluster 3.
clusters2 <- cutree(clusterdata2, k=11)
table(clusters2)
## clusters2
## 1 2 3 4 5 6 7 8 9 10 11
## 11 20 10 3 1 2 2 1 1 1 1
aggregate(data, by=list(cluster=clusters2), mean)
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
## cluster State Amethyst Aquamarine Black.Diamond Blue.Topaz Citrine
## 1 1 NA 709.7091 1176.5611 413.4091 933.6424 819.0455
## 2 2 NA 527.4917 430.5833 213.4333 221.2850 91.1500
## 3 3 NA 786.7269 986.6637 900.3242 576.6023 640.9509
## 4 4 NA 727.2269 980.8291 861.9444 585.3393 674.1667
## 5 5 NA 0.0000 0.0000 410.0000 0.0000 0.0000
## 6 6 NA 1375.6806 983.0625 695.4167 773.5833 0.0000
## 7 7 NA 619.5000 322.5000 1544.0000 440.8333 0.0000
## 8 8 NA 325.0000 0.0000 0.0000 0.0000 1060.5000
## 9 9 NA 603.6000 1956.8571 1524.0000 439.3333 526.4286
## 10 10 NA 0.0000 0.0000 0.0000 0.0000 0.0000
## 11 11 NA 566.0000 1059.6000 1399.0000 1374.3333 0.0000
## Diamond Emerald Garnet Morganite Peridot Pink.Sapphire
## 1 59.72727 1084.004 602.1970 746.4545 199.5000 218.3636
## 2 207.15000 1048.989 166.0750 0.0000 221.7750 150.4000
## 3 424.26000 1597.024 845.9365 718.6074 661.3041 513.1615
## 4 3934.16667 1560.593 448.8074 494.0000 581.5667 1093.6667
## 5 0.00000 2031.000 0.0000 0.0000 1400.0000 2512.0000
## 6 1738.00000 1251.493 957.7500 0.0000 706.2500 761.0000
## 7 0.00000 690.000 0.0000 388.7500 272.5000 0.0000
## 8 0.00000 597.500 367.0000 1459.0000 650.0000 0.0000
## 9 0.00000 1388.143 0.0000 2909.0000 315.0000 569.0000
## 10 0.00000 9962.000 0.0000 0.0000 0.0000 0.0000
## 11 0.00000 2135.250 2236.0000 2650.0000 569.5000 595.0000
## Pink.Tourmaline Plain Ruby Sapphire SI.Diamond Tanzanite
## 1 176.1364 356.3939 2086.339 1284.579 682.6061 942.5091
## 2 191.3500 141.2000 805.219 1010.462 543.6833 734.9500
## 3 1180.8651 697.7288 1679.888 1441.845 846.1690 1054.9600
## 4 870.2778 457.8524 1651.193 1991.119 1219.4028 1203.7261
## 5 0.0000 0.0000 3375.000 1802.750 0.0000 332.0000
## 6 292.7500 419.6667 2087.017 1382.628 2208.5000 1037.2500
## 7 236.0000 964.7500 1069.375 1189.143 0.0000 1648.6667
## 8 2191.0000 455.0000 1612.600 3147.500 589.0000 349.0000
## 9 673.0000 377.0000 1763.100 1262.250 807.5000 909.8571
## 10 0.0000 0.0000 0.000 0.000 2592.0000 1377.0000
## 11 0.0000 399.0000 3019.250 1050.833 1316.0000 1435.0000
## VS.Diamond VVS.Diamond White.Sapphire White.Topaz Grand.Total
## 1 693.9091 89.36364 124.2424 257.1818 1105.631
## 2 492.2000 67.75000 154.6350 103.8500 1040.743
## 3 1031.7467 1110.83000 595.6732 384.6711 1186.533
## 4 1918.0667 0.00000 559.3333 586.1667 1217.014
## 5 0.0000 0.00000 0.0000 698.0000 1531.750
## 6 370.0000 4662.50000 683.5000 228.6667 1284.768
## 7 747.6667 416.00000 129.5000 1458.0000 1005.998
## 8 0.0000 0.00000 0.0000 0.0000 1187.000
## 9 3081.0000 0.00000 554.0000 648.0000 1154.123
## 10 0.0000 0.00000 0.0000 0.0000 4643.667
## 11 0.0000 0.00000 473.0000 0.0000 1412.578
aggregate(data[,-1], by=list(cluster=clusters2), median)
## cluster Amethyst Aquamarine Black.Diamond Blue.Topaz Citrine Diamond
## 1 1 684.5000 1202.1250 471.0000 876.0000 741.0000 0
## 2 2 480.1250 338.0000 0.0000 0.0000 0.0000 0
## 3 3 796.4786 932.5694 954.8333 556.6000 647.8333 0
## 4 4 761.1250 972.3750 998.5000 563.1429 800.5000 3752
## 5 5 0.0000 0.0000 410.0000 0.0000 0.0000 0
## 6 6 1375.6806 983.0625 695.4167 773.5833 0.0000 1738
## 7 7 619.5000 322.5000 1544.0000 440.8333 0.0000 0
## 8 8 325.0000 0.0000 0.0000 0.0000 1060.5000 0
## 9 9 603.6000 1956.8571 1524.0000 439.3333 526.4286 0
## 10 10 0.0000 0.0000 0.0000 0.0000 0.0000 0
## 11 11 566.0000 1059.6000 1399.0000 1374.3333 0.0000 0
## Emerald Garnet Morganite Peridot Pink.Sapphire Pink.Tourmaline
## 1 1080.143 536.3333 881.00 0.0000 0 0.000
## 2 1083.917 0.0000 0.00 0.0000 0 0.000
## 3 1484.920 698.1049 743.00 699.0152 0 1172.234
## 4 1728.222 465.5556 0.00 628.5000 1150 864.200
## 5 2031.000 0.0000 0.00 1400.0000 2512 0.000
## 6 1251.493 957.7500 0.00 706.2500 761 292.750
## 7 690.000 0.0000 388.75 272.5000 0 236.000
## 8 597.500 367.0000 1459.00 650.0000 0 2191.000
## 9 1388.143 0.0000 2909.00 315.0000 569 673.000
## 10 9962.000 0.0000 0.00 0.0000 0 0.000
## 11 2135.250 2236.0000 2650.00 569.5000 595 0.000
## Plain Ruby Sapphire SI.Diamond Tanzanite VS.Diamond VVS.Diamond
## 1 310.0000 2049.500 1338.818 732.500 1000.0000 0.0000 0.0
## 2 0.0000 468.500 987.500 0.000 643.0000 0.0000 0.0
## 3 658.9762 1676.633 1524.663 1005.500 1104.8475 1269.5000 652.5
## 4 456.5000 1434.667 2109.300 1075.333 1181.7895 2425.2000 0.0
## 5 0.0000 3375.000 1802.750 0.000 332.0000 0.0000 0.0
## 6 419.6667 2087.017 1382.628 2208.500 1037.2500 370.0000 4662.5
## 7 964.7500 1069.375 1189.143 0.000 1648.6667 747.6667 416.0
## 8 455.0000 1612.600 3147.500 589.000 349.0000 0.0000 0.0
## 9 377.0000 1763.100 1262.250 807.500 909.8571 3081.0000 0.0
## 10 0.0000 0.000 0.000 2592.000 1377.0000 0.0000 0.0
## 11 399.0000 3019.250 1050.833 1316.000 1435.0000 0.0000 0.0
## White.Sapphire White.Topaz Grand.Total
## 1 0.0 0.0000 1050.000
## 2 0.0 0.0000 1096.424
## 3 646.6 519.4167 1191.793
## 4 783.0 574.5000 1283.598
## 5 0.0 698.0000 1531.750
## 6 683.5 228.6667 1284.768
## 7 129.5 1458.0000 1005.998
## 8 0.0 0.0000 1187.000
## 9 554.0 648.0000 1154.123
## 10 0.0 0.0000 4643.667
## 11 473.0 0.0000 1412.578
plot(clusterdata2, hang=-1, cex=.8,main="Average Linkage Clustering\n11 Cluster Solution")
rect.hclust(clusterdata2, k=11)
c2 <- data.frame(data$State,clusters2)
a2<-c2$data.State[c1$clusters2==1]
b2<-c2$data.State[c1$clusters2==2]
library(cluster)
set.seed(789)
data<-data[1:52,]
rownames(data) <- data$State
pamdata <- pam(data[-1], k=2, stand=TRUE)
pamdata$medoids
## Amethyst Aquamarine Black.Diamond Blue.Topaz Citrine Diamond
## Ohio 677.75 763.8 1323.5 0 862 433
## Montana 533.25 480.0 0.0 0 0 0
## Emerald Garnet Morganite Peridot Pink.Sapphire Pink.Tourmaline
## Ohio 1826.412 1114 790 586.5 0 635
## Montana 644.000 0 0 0.0 0 0
## Plain Ruby Sapphire SI.Diamond Tanzanite VS.Diamond
## Ohio 530.75 1512.833 1505.778 1029 622.125 0
## Montana 0.00 0.000 1675.000 482 1539.500 0
## VVS.Diamond White.Sapphire White.Topaz Grand.Total
## Ohio 0 495 0 1118.299
## Montana 0 0 0 849.300
clusplot(pamdata, main="Cluster Plot")
ct.pam <- table(data$State, pamdata$clustering)
summary(pamdata)
## Medoids:
## ID Amethyst Aquamarine Black.Diamond Blue.Topaz Citrine Diamond
## Ohio 37 677.75 763.8 1323.5 0 862 433
## Montana 28 533.25 480.0 0.0 0 0 0
## Emerald Garnet Morganite Peridot Pink.Sapphire Pink.Tourmaline
## Ohio 1826.412 1114 790 586.5 0 635
## Montana 644.000 0 0 0.0 0 0
## Plain Ruby Sapphire SI.Diamond Tanzanite VS.Diamond
## Ohio 530.75 1512.833 1505.778 1029 622.125 0
## Montana 0.00 0.000 1675.000 482 1539.500 0
## VVS.Diamond White.Sapphire White.Topaz Grand.Total
## Ohio 0 495 0 1118.299
## Montana 0 0 0 849.300
## Clustering vector:
## Alabama Alaska Alberta Arizona Arkansas
## 1 2 2 1 2
## Armed Forces California Colorado Connecticut Delaware
## 2 1 1 2 2
## Florida Georgia Hawaii Idaho Illinois
## 1 1 1 2 1
## Indiana Iowa Kansas Kentucky Louisiana
## 1 1 1 2 1
## Maine Maryland Massachusetts Michigan Minnesota
## 2 1 1 1 1
## Mississippi Missouri Montana Nebraska Nevada
## 2 1 2 1 1
## New Hampshire New Jersey New Mexico New York North Carolina
## 2 1 2 1 1
## North Dakota Ohio Oklahoma Oregon Pennsylvania
## 1 1 1 1 1
## Rhode Island South Carolina South Dakota Tennessee Texas
## 1 1 2 1 1
## Utah Vermont Virginia Washington West Virginia
## 2 2 1 1 2
## Wisconsin Wyoming
## 1 2
## Objective function:
## build swap
## 6.477915 6.438597
##
## Numerical information per cluster:
## size max_diss av_diss diameter separation
## [1,] 34 21.73284 6.858750 23.75496 4.634538
## [2,] 18 9.93505 5.644976 11.81608 4.634538
##
## Isolated clusters:
## L-clusters: character(0)
## L*-clusters: character(0)
##
## Silhouette plot information:
## cluster neighbor sil_width
## Florida 1 2 0.1503071132
## California 1 2 0.1437597228
## New York 1 2 0.1383340516
## Arizona 1 2 0.1319183678
## South Carolina 1 2 0.1272512494
## Massachusetts 1 2 0.1196627294
## Maryland 1 2 0.1063676787
## Texas 1 2 0.1023169331
## North Carolina 1 2 0.0860813673
## Tennessee 1 2 0.0846385910
## New Jersey 1 2 0.0821861397
## Pennsylvania 1 2 0.0711451448
## Ohio 1 2 0.0652021086
## Illinois 1 2 0.0594267018
## Minnesota 1 2 0.0465182555
## Colorado 1 2 0.0394459137
## Missouri 1 2 0.0370280696
## Virginia 1 2 0.0356382673
## Michigan 1 2 0.0232531280
## Louisiana 1 2 0.0028592824
## North Dakota 1 2 0.0009838071
## Washington 1 2 -0.0003758998
## Nebraska 1 2 -0.0228369100
## Oregon 1 2 -0.0380125358
## Georgia 1 2 -0.0405276658
## Indiana 1 2 -0.0519177327
## Hawaii 1 2 -0.0531651135
## Oklahoma 1 2 -0.0558880262
## Kansas 1 2 -0.0565971103
## Wisconsin 1 2 -0.0592056713
## Rhode Island 1 2 -0.0749345491
## Alabama 1 2 -0.1103860744
## Iowa 1 2 -0.1146202310
## Nevada 1 2 -0.1389059595
## South Dakota 2 1 0.3229943523
## Vermont 2 1 0.3184603233
## Montana 2 1 0.3102890220
## Alberta 2 1 0.2687780632
## Mississippi 2 1 0.2438581841
## Armed Forces 2 1 0.2406387304
## West Virginia 2 1 0.2229990570
## Arkansas 2 1 0.2090135485
## New Hampshire 2 1 0.2046689836
## Maine 2 1 0.1663806191
## Wyoming 2 1 0.1536789472
## Idaho 2 1 0.1469198952
## Kentucky 2 1 0.1391266121
## Delaware 2 1 0.1316644826
## Alaska 2 1 0.1239947645
## New Mexico 2 1 0.1208823242
## Connecticut 2 1 0.1148016579
## Utah 2 1 0.0263036850
## Average silhouette width per cluster:
## [1] 0.02461621 0.19252518
## Average silhouette width of total data set:
## [1] 0.08273855
##
## 1326 dissimilarities, summarized :
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.6227 6.9616 8.2351 8.8040 9.7861 25.3270
## Metric : euclidean
## Number of objects : 52
##
## Available components:
## [1] "medoids" "id.med" "clustering" "objective" "isolation"
## [6] "clusinfo" "silinfo" "diss" "call" "data"
pamdataframe <- as.data.frame(pamdata$clustering)
c3 <- data.frame(data$State[-53],pamdataframe)
a3<-c3$data.State..53.[c3$pamdata.clustering==1]
b3<-c3$data.State..53.[c3$pamdata.clustering==2]
# I ve broken the data into 2 clusters, the 2 medoid are Ohio and Montana. The higher avg price states are placed in the ohio medoid. COmparing the 2 results, we see a lot of similarities. California, Ohio, Florida, Georgia, arizona etc are all in cluster 1 (for the medoids methoda as well as cutree.) Hence, these states most likely have a higer average price across gemstones and we can target our customers accordingly.
highspendingstates<-intersect(a,a3)
lowspendingstates<-intersect(b,b3)
highspendingstates
## [1] "Alabama" "Arizona" "California" "Florida"
## [5] "Georgia" "Indiana" "Iowa" "Louisiana"
## [9] "Massachusetts" "Michigan" "Minnesota" "Missouri"
## [13] "New Jersey" "New York" "North Carolina" "Ohio"
## [17] "Oklahoma" "Rhode Island" "Tennessee" "Texas"
## [21] "Virginia" "Washington"
lowspendingstates
## [1] "Alaska" "Alberta" "Arkansas" "Armed Forces"
## [5] "Connecticut" "Idaho" "Kentucky" "Maine"
## [9] "Mississippi" "Montana" "New Hampshire" "New Mexico"
## [13] "South Dakota" "Vermont" "West Virginia" "Wyoming"
hi<-as.matrix(clusters)
pamcv<-as.matrix(pamdata$clustering)
#trying to validate clusters.
library(clValid)
hi.cv<-clValid(hi,11,clMethods = c("hierarchical"),validation="internal")
pamcv.cv<-clValid(pamcv,2,clMethods = c("pam"),validation="internal")
summary(hi.cv)
##
## Clustering Methods:
## hierarchical
##
## Cluster sizes:
## 11
##
## Validation Measures:
## 11
##
## hierarchical Connectivity 28.2187
## Dunn Inf
## Silhouette 0.8679
##
## Optimal Scores:
##
## Score Method Clusters
## Connectivity 28.2187 hierarchical 11
## Dunn Inf hierarchical 11
## Silhouette 0.8679 hierarchical 11
summary(pamcv.cv)
##
## Clustering Methods:
## pam
##
## Cluster sizes:
## 2
##
## Validation Measures:
## 2
##
## pam Connectivity 0
## Dunn Inf
## Silhouette 1
##
## Optimal Scores:
##
## Score Method Clusters
## Connectivity 0 pam 2
## Dunn Inf pam 2
## Silhouette 1 pam 2
#connectivity is lower for Pam and silhouette is higher for Pam, so it appears to be the better form of clustering.
#Connectivity - what extent items are placed in the same cluster as their nearest neighbors in the data space. It has a value between 0 and infinity and should be minimized.
#Average Silhouette width - It lies between -1 (poorly clustered observations) to 1 (well clustered observations). It should be maximized.
library(xlsx)
## Loading required package: rJava
## Loading required package: xlsxjars
library(plyr)
## -------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## -------------------------------------------------------------------------
##
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following object is masked from 'package:purrr':
##
## compact
## The following objects are masked from 'package:Hmisc':
##
## is.discrete, summarize
library(dplyr)
library(cluster)
library(flexclust)
## Loading required package: grid
## Loading required package: modeltools
## Loading required package: stats4
##
## Attaching package: 'modeltools'
## The following object is masked from 'package:plyr':
##
## empty
## The following object is masked from 'package:rJava':
##
## clone
## The following object is masked from 'package:clValid':
##
## clusters
x <- read.xlsx("Files/Anish/Sales cluster dataset.xlsx",2)
x[is.na(x)] <- 0
glimpse(x)
## Observations: 51
## Variables: 8
## $ State <fctr> Alabama, Alaska, Arizona, Arkansas, Armed Forces, C...
## $ Sunday <dbl> 6, 0, 2, 0, 0, 5, 0, 2, 2, 3, 3, 1, 1, 5, 1, 5, 1, 4...
## $ Monday <dbl> 3, 2, 7, 4, 2, 9, 3, 3, 2, 4, 5, 3, 3, 0, 3, 4, 3, 6...
## $ Tuesday <dbl> 4, 1, 9, 6, 0, 4, 5, 2, 4, 7, 4, 5, 7, 6, 3, 12, 2, ...
## $ Wednesday <dbl> 7, 4, 9, 1, 2, 6, 1, 4, 3, 6, 7, 2, 0, 1, 1, 5, 5, 3...
## $ Thursday <dbl> 6, 3, 9, 2, 0, 7, 0, 1, 2, 8, 4, 3, 6, 7, 3, 9, 3, 3...
## $ Friday <dbl> 5, 2, 7, 1, 0, 4, 1, 1, 3, 13, 5, 5, 8, 3, 2, 7, 2, ...
## $ Saturday <dbl> 5, 3, 8, 1, 1, 2, 0, 3, 1, 2, 0, 1, 4, 7, 2, 5, 0, 2...
rownames(x) <- x$State
#The data needs to be scaled to run the clustering algorithm
scaled <- data.frame(scale(x[,2:8]))
scaledx <- data.frame(scaled)
rownames(scaledx) <- x$State
#A distance formula needs to be run to calculate distances on the scaled data frame
distx <- dist(scaledx,method = "euclidean")
#This is the average linkage clustering
fit.average <- hclust(distx, method="average")
plot(fit.average, hang=-1, cex=.8, main="Average Linkage Clustering")
#Let's split into 3 clusters
clusters <- cutree(fit.average, k=3)
table(clusters)
## clusters
## 1 2 3
## 47 1 3
#These are the average mean and medians of the clusters
#Looks like cluster 1 has low number of sales, cluster 2 has the highest and cluster 3 has the second highest. Clusters 2 and 3 means are close to each other compared to cluster 1 but the difference is a bit more pronounced in the medians.
aggregate(x[,-1], by=list(cluster=clusters), mean)
## cluster Sunday Monday Tuesday Wednesday Thursday Friday
## 1 1 3.914894 5.93617 6.212766 6 6.12766 6.446809
## 2 2 25.000000 45.00000 37.000000 51 55.00000 53.000000
## 3 3 22.000000 28.66667 30.000000 34 27.33333 29.000000
## Saturday
## 1 4.00000
## 2 51.00000
## 3 23.33333
aggregate(x[,-1], by=list(cluster=clusters), median)
## cluster Sunday Monday Tuesday Wednesday Thursday Friday Saturday
## 1 1 3 4 5 4 6 4 3
## 2 2 25 45 37 51 55 53 51
## 3 3 19 28 31 35 29 29 27
plot(fit.average, hang=-1, cex=.8,
main="Average Linkage Clustering\n3 Cluster Solution")
#It has split up CA into its own cluster, NY, FL & TX into their own cluster as the second best performing and all the other states into one big cluster of their own
rect.hclust(fit.average, k=3)
plot(silhouette(clusters, distx), main = "HClust Silhouette Plot")
#Let's see the results by running another clustering algorithm - Partitioning around medoids
pamcluster <- pam(distx, 3, diss=TRUE, stand=TRUE)
#Looks like this algorithm has grouped the states differently from the earlier algorithm.
# The top 4 states CA, NY, TX, and FL have been put into their own cluster followed by the next 13 states in the second cluster followed by the rest into the 3rd cluster. This seems like a better result.
summary(pamcluster)
## Medoids:
## ID
## [1,] "25" "Oklahoma"
## [2,] "38" "Texas"
## [3,] "47" "Ohio"
## Clustering vector:
## Alabama Alaska Arizona Arkansas Armed Forces
## 1 1 1 1 1
## Connecticut Delaware Hawaii Idaho Indiana
## 1 1 1 1 1
## Iowa Kansas Kentucky Louisiana Maine
## 1 1 1 1 1
## Minnesota Mississippi Missouri Montana Nebraska
## 1 1 1 1 1
## Nevada New Hampshire New Mexico North Dakota Oklahoma
## 1 1 1 1 1
## Oregon Rhode Island South Carolina South Dakota Utah
## 1 1 1 1 1
## Vermont West Virginia Wisconsin Wyoming California
## 1 1 1 1 2
## Florida New York Texas Colorado Georgia
## 2 2 2 3 3
## Illinois Maryland Massachusetts Michigan New Jersey
## 3 3 3 3 3
## North Carolina Ohio Pennsylvania Tennessee Virginia
## 3 3 3 3 3
## Washington
## 3
## Objective function:
## build swap
## 0.9740851 0.9521850
##
## Numerical information per cluster:
## size max_diss av_diss diameter separation
## [1,] 34 1.354657 0.6832387 2.114534 0.9363351
## [2,] 4 4.967819 2.5835405 6.257107 3.7055411
## [3,] 13 1.788970 1.1536273 2.407475 0.9363351
##
## Isolated clusters:
## L-clusters: character(0)
## L*-clusters: character(0)
##
## Silhouette plot information:
## cluster neighbor sil_width
## Maine 1 3 0.75579229
## Idaho 1 3 0.74725942
## Oklahoma 1 3 0.74722865
## Wyoming 1 3 0.74164774
## New Mexico 1 3 0.73701700
## Hawaii 1 3 0.73495325
## Mississippi 1 3 0.73139719
## Alaska 1 3 0.72711654
## West Virginia 1 3 0.72549808
## Montana 1 3 0.72500073
## Kansas 1 3 0.72179314
## Armed Forces 1 3 0.72009023
## Rhode Island 1 3 0.71783910
## Vermont 1 3 0.71365923
## Delaware 1 3 0.71071113
## North Dakota 1 3 0.71040391
## Nevada 1 3 0.70685791
## South Dakota 1 3 0.70517227
## Arkansas 1 3 0.70479485
## Nebraska 1 3 0.69977038
## New Hampshire 1 3 0.69951552
## Utah 1 3 0.65967874
## Iowa 1 3 0.63989827
## Kentucky 1 3 0.59416727
## Missouri 1 3 0.59246419
## Louisiana 1 3 0.54440144
## Wisconsin 1 3 0.52953656
## Alabama 1 3 0.51219590
## Connecticut 1 3 0.47290892
## Oregon 1 3 0.43841043
## Indiana 1 3 0.35776295
## South Carolina 1 3 0.35209659
## Minnesota 1 3 0.22171289
## Arizona 1 3 0.20380224
## Texas 2 3 0.42825283
## California 2 3 0.42488334
## Florida 2 3 0.20099615
## New York 2 3 0.12759960
## Pennsylvania 3 1 0.59566169
## Illinois 3 1 0.56912339
## Ohio 3 1 0.56764758
## New Jersey 3 1 0.56303216
## Virginia 3 1 0.55958231
## Colorado 3 1 0.52409034
## North Carolina 3 1 0.51606267
## Michigan 3 1 0.39816893
## Maryland 3 1 0.38508030
## Washington 3 1 0.35056776
## Massachusetts 3 1 0.18693317
## Georgia 3 1 0.18298426
## Tennessee 3 1 -0.02814095
## Average silhouette width per cluster:
## [1] 0.6265457 0.2954330 0.4131380
## Average silhouette width of total data set:
## [1] 0.546178
##
## Available components:
## [1] "medoids" "id.med" "clustering" "objective" "isolation"
## [6] "clusinfo" "silinfo" "diss" "call"
clusplot(pamcluster, main="Bivariate Cluster Plot")
pamcluster$medoids
## [1] "Oklahoma" "Texas" "Ohio"
plot(silhouette(pamcluster, distx), main = "PAM Silhouette Plot")
d <- as.data.frame(pamcluster$clustering)
pamdataset <- data.frame(x,d)
aggregate(pamdataset[,-1], by=list(pamdataset[,9]), mean)
## Group.1 Sunday Monday Tuesday Wednesday Thursday Friday
## 1 1 2.147059 3.264706 3.794118 3.088235 3.705882 3.411765
## 2 2 22.750000 32.750000 31.750000 38.250000 34.250000 35.000000
## 3 3 8.538462 12.923077 12.538462 13.615385 12.461538 14.384615
## Saturday pamcluster.clustering
## 1 2.441176 1
## 2 30.250000 2
## 3 8.076923 3
aggregate(pamdataset[,-1], by=list(pamdataset[,9]), median)
## Group.1 Sunday Monday Tuesday Wednesday Thursday Friday Saturday
## 1 1 2 3.0 4 3 3.0 2.0 2
## 2 2 22 29.5 32 35 31.5 34.5 27
## 3 3 10 14.0 12 15 13.0 14.0 8
## pamcluster.clustering
## 1 1
## 2 2
## 3 3
#Average linkage clustering shows CA as the top performing state followed by NY, FL, & TX but then combines everything else together.
#PAM clustering seems to have split the results into a better cluster of
#Top states = CA, NY, TX, FL
#Middle States = CO, GA, IL, MD, MA, MI, NJ, NC, OH, PA, TN, VA, WA
#Low performing = The rest.
# The reason I prefer PAM for this dataset is because though both select the same 4 states as the top performers, PAM gives more insight into the middle and low performing states.
library(NbClust)
nc <- NbClust(scaledx,distance = "euclidean",min.nc = 2, max.nc = 15,method = "average")
## Warning in pf(beale, pp, df2): NaNs produced
## Warning in pf(beale, pp, df2): NaNs produced
## [1] "Frey index : No clustering structure in this data set"
## *** : The Hubert index is a graphical method of determining the number of clusters.
## In the plot of Hubert index, we seek a significant knee that corresponds to a
## significant increase of the value of the measure i.e the significant peak in Hubert
## index second differences plot.
##
## *** : The D index is a graphical method of determining the number of clusters.
## In the plot of D index, we seek a significant knee (the significant peak in Dindex
## second differences plot) that corresponds to a significant increase of the value of
## the measure.
##
## *******************************************************************
## * Among all indices:
## * 6 proposed 2 as the best number of clusters
## * 5 proposed 3 as the best number of clusters
## * 2 proposed 4 as the best number of clusters
## * 4 proposed 5 as the best number of clusters
## * 1 proposed 6 as the best number of clusters
## * 4 proposed 10 as the best number of clusters
## * 1 proposed 14 as the best number of clusters
##
## ***** Conclusion *****
##
## * According to the majority rule, the best number of clusters is 2
##
##
## *******************************************************************
table(nc$Best.n[1,])
##
## 0 2 3 4 5 6 10 14
## 2 6 5 2 4 1 4 1
barplot(table(nc$Best.n[1,]),
xlab="Number of Clusters", ylab="Number of Criteria",
main="Number of Clusters Chosen by 26 Criteria")
#We split up the data into 3 clusters above. The NbClust algorithm suggests 2 or 3 clusters as appropriate
cvhclust <- as.matrix(clusters)
cvpam <- as.matrix(pamcluster$clustering)
library(clValid)
hclust.cved <- clValid(cvhclust, 2:5, clMethods = c("hierarchical"), validation = "internal")
summary(hclust.cved)
##
## Clustering Methods:
## hierarchical
##
## Cluster sizes:
## 2 3 4 5
##
## Validation Measures:
## 2 3 4 5
##
## hierarchical Connectivity 4.2869 7.2159 9.2159 10.2159
## Dunn 1.0000 Inf NaN NaN
## Silhouette 0.9706 0.9804 0.9216 0.9216
##
## Optimal Scores:
##
## Score Method Clusters
## Connectivity 4.2869 hierarchical 2
## Dunn Inf hierarchical 3
## Silhouette 0.9804 hierarchical 3
pam.cved <- clValid(cvpam, 2:5, clMethods = c("pam"), validation = "internal")
summary(pam.cved)
##
## Clustering Methods:
## pam
##
## Cluster sizes:
## 2 3 4 5
##
## Validation Measures:
## 2 3 4 5
##
## pam Connectivity 0.0000 4.3825 7.3115 10.2405
## Dunn 1.0000 Inf NaN NaN
## Silhouette 0.8919 1.0000 0.7451 0.7451
##
## Optimal Scores:
##
## Score Method Clusters
## Connectivity 0 pam 2
## Dunn Inf pam 3
## Silhouette 1 pam 3
#Since PAM has a lower Connectivity and higher Silhouette, it seems like that is a better clustering fit to the data. Also, looking at the various clusters, it does seem like 3 clusters is the optimal number of clusters.
Create a bivariate distribution with function rnorm2d(). Below is a 3D representation of a bivariate distribution. Since the means are centered in the 2D space, there are no clusters to be found.
Bivariate_Plot
library(fMultivar)
## Loading required package: timeDate
## Loading required package: timeSeries
## Loading required package: fBasics
##
## Rmetrics Package fBasics
## Analysing Markets and calculating Basic Statistics
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: info@rmetrics.org
##
## Attaching package: 'fBasics'
## The following object is masked from 'package:flexclust':
##
## getModel
## The following object is masked from 'package:modeltools':
##
## getModel
##
## Rmetrics Package fMultivar
## Analysing and Modeling Multivariate Financial Return Distributions
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: info@rmetrics.org
library(dplyr)
set.seed(1234)
df <- rnorm2d(1000, rho=.5) %>% as.data.frame()
plot(df, main="Bivariate Normal Distribution with rho=0.5")
From the within-groups sum of squares plot, we see that the analysis suggests 2 or 3 clusters in the data.
Using NbClust() and specifying the clustering method as “kmeans”, the result suggests the data has 2 clusters in it.
wssplot <- function(data, nc=15, seed=1234){
wss <- (nrow(data)-1)*sum(apply(data,2,var))
for (i in 2:nc){
set.seed(seed)
wss[i] <- sum(kmeans(data, centers=i)$withinss)}
plot(1:nc, wss, type="b", xlab="Number of Clusters",
ylab="Within groups sum of squares")}
wssplot(df)
library(NbClust)
#nc <- NbClust(df, min.nc=2, max.nc=15, method="kmeans")
#saveRDS(nc, file = "nc.rds")
nc <- readRDS(file = "Files/Ryan/nc.rds")
barplot(table(nc$Best.n[1,]),
xlab="Number of Clusters", ylab="Number of Criteria",
main="Number of Clusters Chosen by 26 Criteria")
library(ggplot2)
library(cluster)
fit <- pam(df, k=2) # fit the clusters
df$clustering <- fit$clustering %>% factor() # add the cluster tags to the main DF
ggplot(data=df, aes(x=V1, y=V2, color=clustering, shape=clustering)) +
geom_point() +
ggtitle("Clustering of Bivariate Normal Data")
Kabakoff suggests the “Cubic Clustering Criteria” (CCC), part of the NbClust report, but first gives the disclaimer that “it isn’t foolproof”.
In a broad overview, CCC compares the R^2 you get with a given number of clusters with the R^2 you would get with a uniform distribution. So, the largest difference is what you are after.
With CCC, the best number of clusters will correspond to a local maxima of the CCC index.
If you see a continuously decreasing CCC, then it suggests there are no clusters present.
In summary, analysis of the results from NbClust looking at within sum of squares and NbClusts’ “26 criteria” suggested 2 clusters were present. The indicator that strongly suggested otherwise was the CCC.
In cluster analysis and with all modeling, it is important to not overfit your data and use your intuition and knowledge of the data to deduce what is and is not trend.
plot(nc$All.index[,4], type="o", ylab="CCC",
xlab="Number of clusters", col="blue")